Move Integration Tests to dedicated project (#201)

Add IntegrationTests project. Move all tests ifdef'd with LIVE_CONNECTION_TESTS to IntegrationTests project. Delete files that have no remaining code. Update codecoverage.bat to run integration tests
This commit is contained in:
Connor Quagliana
2017-01-04 11:37:57 -08:00
committed by GitHub
parent 5b41538d22
commit 3ad7cc1a8b
16 changed files with 647 additions and 435 deletions

View File

@@ -18,9 +18,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.LanguageServer
/// </summary>
public class LanguageServiceTests
{
#region "Diagnostics tests"
/// <summary>
/// Verify that the latest SqlParser (2016 as of this writing) is used by default
/// </summary>
@@ -197,134 +194,5 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.LanguageServer
AutoCompleteHelper.GetDefaultCompletionItems(scriptDocumentInfo, false);
}
#endregion
#region "General Language Service tests"
#if LIVE_CONNECTION_TESTS
private static void GetLiveAutoCompleteTestObjects(
out TextDocumentPosition textDocument,
out ScriptFile scriptFile,
out ConnectionInfo connInfo)
{
textDocument = new TextDocumentPosition
{
TextDocument = new TextDocumentIdentifier {Uri = TestObjects.ScriptUri},
Position = new Position
{
Line = 0,
Character = 0
}
};
connInfo = TestObjects.InitLiveConnectionInfo(out scriptFile);
}
/// <summary>
/// Test the service initialization code path and verify nothing throws
/// </summary>
[Fact]
public void ServiceInitialization()
{
try
{
TestObjects.InitializeTestServices();
}
catch (System.ArgumentException)
{
}
Assert.True(LanguageService.Instance.Context != null);
Assert.True(LanguageService.ConnectionServiceInstance != null);
Assert.True(LanguageService.Instance.CurrentSettings != null);
Assert.True(LanguageService.Instance.CurrentWorkspace != null);
}
/// <summary>
/// Test the service initialization code path and verify nothing throws
/// </summary>
[Fact]
public void PrepopulateCommonMetadata()
{
ScriptFile scriptFile;
ConnectionInfo connInfo = TestObjects.InitLiveConnectionInfo(out scriptFile);
ScriptParseInfo scriptInfo = new ScriptParseInfo {IsConnected = true};
AutoCompleteHelper.PrepopulateCommonMetadata(connInfo, scriptInfo, null);
}
// This test currently requires a live database connection to initialize
// SMO connected metadata provider. Since we don't want a live DB dependency
// in the CI unit tests this scenario is currently disabled.
[Fact]
public void AutoCompleteFindCompletions()
{
TextDocumentPosition textDocument;
ConnectionInfo connInfo;
ScriptFile scriptFile;
GetLiveAutoCompleteTestObjects(out textDocument, out scriptFile, out connInfo);
textDocument.Position.Character = 7;
scriptFile.Contents = "select ";
var autoCompleteService = LanguageService.Instance;
var completions = autoCompleteService.GetCompletionItems(
textDocument,
scriptFile,
connInfo);
Assert.True(completions.Length > 0);
}
/// <summary>
/// Verify that GetSignatureHelp returns not null when the provided TextDocumentPosition
/// has an associated ScriptParseInfo and the provided query has a function that should
/// provide signature help.
/// </summary>
// turn-off broken test until it can be fixed
//[Fact]
public async void GetSignatureHelpReturnsNotNullIfParseInfoInitialized()
{
// When we make a connection to a live database
ScriptFile scriptFile;
Hosting.ServiceHost.SendEventIgnoreExceptions = true;
ConnectionInfo connInfo = TestObjects.InitLiveConnectionInfo(out scriptFile);
// And we place the cursor after a function that should prompt for signature help
string queryWithFunction = "EXEC sys.fn_isrolemember ";
scriptFile.Contents = queryWithFunction;
TextDocumentPosition textDocument = new TextDocumentPosition
{
TextDocument = new TextDocumentIdentifier
{
Uri = scriptFile.ClientFilePath
},
Position = new Position
{
Line = 0,
Character = queryWithFunction.Length
}
};
// If the SQL has already been parsed
var service = LanguageService.Instance;
await service.UpdateLanguageServiceOnConnection(connInfo);
// We should get back a non-null ScriptParseInfo
ScriptParseInfo parseInfo = service.GetScriptParseInfo(scriptFile.ClientFilePath);
Assert.NotNull(parseInfo);
// And we should get back a non-null SignatureHelp
SignatureHelp signatureHelp = service.GetSignatureHelp(textDocument, scriptFile);
Assert.NotNull(signatureHelp);
}
#endif
#endregion
}
}