Add additional test cases (#125)

Test-only changes for code coverage.  Please review the comment and I'll include the changes in the next iteration.

* Add more tests

* Add some more additional test cases
This commit is contained in:
Karl Burtram
2016-10-28 20:33:32 -07:00
committed by GitHub
parent 931235c604
commit f46fc0c787
9 changed files with 732 additions and 106 deletions

View File

@@ -62,8 +62,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Driver
{
coverageOutput = "coverage.xml";
}
serviceHostArguments = "-target:" + serviceHostExecutable + " -targetargs:" + serviceHostArguments
serviceHostArguments = "-mergeoutput -target:" + serviceHostExecutable + " -targetargs:" + serviceHostArguments
+ " -register:user -oldstyle -filter:\"+[Microsoft.SqlTools.*]* -[xunit*]*\" -output:" + coverageOutput + " -searchdirs:" + serviceHostDirectory;
serviceHostExecutable = coverageToolPath;

View File

@@ -8,6 +8,9 @@ using System.Reflection;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.TestDriver.Driver;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Xunit;
[assembly: CollectionBehavior(DisableTestParallelization = true)]
namespace Microsoft.SqlTools.ServiceLayer.TestDriver
{

View File

@@ -0,0 +1,45 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
using Microsoft.SqlTools.ServiceLayer.TestDriver.Utility;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
{
/// <summary>
/// Language Service end-to-end integration tests
/// </summary>
public class ConnectionTests : TestBase
{
/// <summary>
/// Try to connect with invalid credentials
/// </summary>
//[Fact]
public async Task InvalidConnection()
{
try
{
string ownerUri = System.IO.Path.GetTempFileName();
bool connected = await Connect(ownerUri, ConnectionTestUtils.InvalidConnection);
Assert.False(connected, "Invalid connection is failed to connect");
await Disconnect(ownerUri);
}
finally
{
WaitForExit();
}
}
}
}

View File

@@ -155,7 +155,6 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
string query = "SELECT *** FROM sys.objects";
DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification()
{
TextDocument = new TextDocumentItem()
@@ -168,7 +167,6 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
};
await RequestOpenDocumentNotification(openParams);
Thread.Sleep(5000);

View File

@@ -10,12 +10,52 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.TestDriver.Utility;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
{
public class QueryExecutionTests : TestBase
{
[Fact]
public async Task ExecuteBasicQueryTest()
{
try
{
string ownerUri = System.IO.Path.GetTempFileName();
bool connected = await Connect(ownerUri, ConnectionTestUtils.LocalhostConnection);
Assert.True(connected, "Connection is successful");
Thread.Sleep(500);
string query = "SELECT * FROM sys.objects";
DidOpenTextDocumentNotification openParams = new DidOpenTextDocumentNotification()
{
TextDocument = new TextDocumentItem()
{
Uri = ownerUri,
LanguageId = "enu",
Version = 1,
Text = query
}
};
await RequestOpenDocumentNotification(openParams);
var queryResult = await RunQuery(ownerUri, query);
Assert.NotNull(queryResult);
Assert.NotNull(queryResult.BatchSummaries);
await Disconnect(ownerUri);
}
finally
{
WaitForExit();
}
}
//[Fact]
public async Task TestQueryingAfterCompletionRequests()
{
@@ -27,7 +67,6 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
await Connect(ownerUri, ConnectionTestUtils.AzureTestServerConnection);
Enumerable.Range(0, 10).ToList().ForEach(arg => tasks.Add(RequestCompletion(ownerUri, query, 0, 10)));
var queryTask = RunQuery(ownerUri, query);
tasks.Add(queryTask);