mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-24 01:25:42 -05:00
Add more test cases for code coverage (#127)
Next round of code coverage test cases. Please review the commit for next iteration. * Add connection retry tests * More test coverage * Update diagnostics end-to-end test
This commit is contained in:
@@ -3,15 +3,9 @@
|
||||
// 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
|
||||
@@ -24,15 +18,44 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
|
||||
/// <summary>
|
||||
/// Try to connect with invalid credentials
|
||||
/// </summary>
|
||||
//[Fact]
|
||||
[Fact]
|
||||
public async Task InvalidConnection()
|
||||
{
|
||||
try
|
||||
{
|
||||
string ownerUri = System.IO.Path.GetTempFileName();
|
||||
bool connected = await Connect(ownerUri, ConnectionTestUtils.InvalidConnection);
|
||||
bool connected = await Connect(ownerUri, ConnectionTestUtils.InvalidConnection, 300000);
|
||||
Assert.False(connected, "Invalid connection is failed to connect");
|
||||
|
||||
await Connect(ownerUri, ConnectionTestUtils.InvalidConnection, 300000);
|
||||
|
||||
Thread.Sleep(1000);
|
||||
|
||||
await CancelConnect(ownerUri);
|
||||
|
||||
await Disconnect(ownerUri);
|
||||
}
|
||||
finally
|
||||
{
|
||||
WaitForExit();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate list databases request
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task ListDatabasesTest()
|
||||
{
|
||||
try
|
||||
{
|
||||
string ownerUri = System.IO.Path.GetTempFileName();
|
||||
bool connected = await Connect(ownerUri, ConnectionTestUtils.LocalhostConnection);
|
||||
Assert.True(connected, "Connection successful");
|
||||
|
||||
var listDatabaseResult = await ListDatabases(ownerUri);
|
||||
Assert.True(listDatabaseResult.DatabaseNames.Length > 0);
|
||||
|
||||
await Disconnect(ownerUri);
|
||||
}
|
||||
finally
|
||||
|
||||
Reference in New Issue
Block a user