mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Address warnings and (some) nullables (#2013)
This commit is contained in:
@@ -15,7 +15,7 @@ using System.IO;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.AzureFunctions
|
||||
{
|
||||
class AzureFunctionsServiceTests
|
||||
internal sealed class AzureFunctionsServiceTests
|
||||
{
|
||||
private string testAzureFunctionsFolder = Path.Combine("..", "..", "..", "AzureFunctions", "AzureFunctionTestFiles");
|
||||
|
||||
|
||||
@@ -29,14 +29,14 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
|
||||
/// </summary>
|
||||
public class ReliableConnectionTests
|
||||
{
|
||||
internal class TestDataTransferErrorDetectionStrategy : DataTransferErrorDetectionStrategy
|
||||
internal sealed class TestDataTransferErrorDetectionStrategy : DataTransferErrorDetectionStrategy
|
||||
{
|
||||
public bool InvokeCanRetrySqlException(SqlException exception)
|
||||
{
|
||||
return CanRetrySqlException(exception);
|
||||
}
|
||||
}
|
||||
internal class TestSqlAzureTemporaryAndIgnorableErrorDetectionStrategy : SqlAzureTemporaryAndIgnorableErrorDetectionStrategy
|
||||
internal sealed class TestSqlAzureTemporaryAndIgnorableErrorDetectionStrategy : SqlAzureTemporaryAndIgnorableErrorDetectionStrategy
|
||||
{
|
||||
public TestSqlAzureTemporaryAndIgnorableErrorDetectionStrategy()
|
||||
: base (new int[] { 100 })
|
||||
@@ -54,7 +54,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
|
||||
}
|
||||
}
|
||||
|
||||
internal class TestFixedDelayPolicy : FixedDelayPolicy
|
||||
internal sealed class TestFixedDelayPolicy : FixedDelayPolicy
|
||||
{
|
||||
public TestFixedDelayPolicy(
|
||||
IErrorDetectionStrategy strategy,
|
||||
@@ -77,7 +77,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
|
||||
}
|
||||
}
|
||||
|
||||
internal class TestProgressiveRetryPolicy : ProgressiveRetryPolicy
|
||||
internal sealed class TestProgressiveRetryPolicy : ProgressiveRetryPolicy
|
||||
{
|
||||
public TestProgressiveRetryPolicy(
|
||||
IErrorDetectionStrategy strategy,
|
||||
@@ -97,7 +97,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
|
||||
}
|
||||
}
|
||||
|
||||
internal class TestTimeBasedRetryPolicy : TimeBasedRetryPolicy
|
||||
internal sealed class TestTimeBasedRetryPolicy : TimeBasedRetryPolicy
|
||||
{
|
||||
public TestTimeBasedRetryPolicy(
|
||||
IErrorDetectionStrategy strategy,
|
||||
@@ -916,7 +916,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
|
||||
command.UpdatedRowSource = UpdateRowSource.None;
|
||||
Assert.AreEqual(UpdateRowSource.None, command.UpdatedRowSource);
|
||||
Assert.NotNull(command.GetUnderlyingCommand());
|
||||
Assert.Throws<InvalidOperationException>(() => command.ValidateConnectionIsSet());
|
||||
Assert.Throws<InvalidOperationException>(command.ValidateConnectionIsSet);
|
||||
command.Prepare();
|
||||
Assert.NotNull(command.CreateParameter());
|
||||
command.Cancel();
|
||||
|
||||
@@ -30,7 +30,7 @@ using static Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility.LiveConnec
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
|
||||
{
|
||||
class BackupRestoreUrlTests
|
||||
internal sealed class BackupRestoreUrlTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Create simple backup test
|
||||
|
||||
@@ -574,7 +574,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
|
||||
string backUpFilePath = string.Empty;
|
||||
if (backupFileNames != null)
|
||||
{
|
||||
var filePaths = backupFileNames.Select(x => GetBackupFilePath(x));
|
||||
var filePaths = backupFileNames.Select(GetBackupFilePath);
|
||||
backUpFilePath = filePaths.Aggregate((current, next) => current + " ," + next);
|
||||
}
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageServer
|
||||
await langService.HandleDidChangeLanguageFlavorNotification(new LanguageFlavorChangeParams
|
||||
{
|
||||
Uri = scriptFile.ClientUri,
|
||||
Language = LanguageService.SQL_LANG.ToLower(),
|
||||
Language = LanguageService.SQL_LANG.ToLower(System.Globalization.CultureInfo.InvariantCulture),
|
||||
Flavor = "MSSQL"
|
||||
}, eventContextSql.Object);
|
||||
await langService.DelayedDiagnosticsTask; // to ensure completion and validation before moveing to next step
|
||||
@@ -379,7 +379,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageServer
|
||||
await langService.HandleDidChangeLanguageFlavorNotification(new LanguageFlavorChangeParams
|
||||
{
|
||||
Uri = scriptFile.ClientUri,
|
||||
Language = LanguageService.SQL_CMD_LANG.ToLower(),
|
||||
Language = LanguageService.SQL_CMD_LANG.ToLower(System.Globalization.CultureInfo.InvariantCulture),
|
||||
Flavor = "MSSQL"
|
||||
}, eventContextSqlCmd.Object);
|
||||
await langService.DelayedDiagnosticsTask;
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
<PackageId>Microsoft.SqlTools.ServiceLayer.IntegrationTests</PackageId>
|
||||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
|
||||
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
|
||||
<!-- TODO FIX THESE WARNINGS ASAP -->
|
||||
<NoWarn>$(NoWarn);SYSLIB1045;IDE0200;IDE0230;CA1311;CA1852;CA1854</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../src/Microsoft.SqlTools.Hosting/Microsoft.SqlTools.Hosting.csproj" />
|
||||
|
||||
@@ -28,7 +28,7 @@ using static Microsoft.SqlTools.ServiceLayer.ObjectExplorer.ObjectExplorerServic
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
|
||||
{
|
||||
public class ObjectExplorerServiceTests
|
||||
public partial class ObjectExplorerServiceTests
|
||||
{
|
||||
private ObjectExplorerService _service = TestServiceProvider.Instance.ObjectExplorerService;
|
||||
|
||||
@@ -124,10 +124,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
|
||||
{
|
||||
var query = "";
|
||||
string databaseName = "#testDb#";
|
||||
await RunTest(databaseName, query, "TestDb", async (testDbName, session) =>
|
||||
{
|
||||
await ExpandAndVerifyDatabaseNode(testDbName, session);
|
||||
});
|
||||
await RunTest(databaseName, query, "TestDb", ExpandAndVerifyDatabaseNode);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -376,7 +373,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
|
||||
ConnectParams connectParams = TestServiceProvider.Instance.ConnectionProfileService.GetConnectionParameters(TestServerType.OnPrem, databaseName);
|
||||
//connectParams.Connection.Pooling = false;
|
||||
ConnectionDetails details = connectParams.Connection;
|
||||
string uri = ObjectExplorerService.GenerateUri(details);
|
||||
string uri = GenerateUri(details);
|
||||
|
||||
var session = await _service.DoCreateSession(details, uri);
|
||||
Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "OE session created for database: {0}", databaseName));
|
||||
@@ -387,10 +384,10 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
|
||||
{
|
||||
Assert.That(session, Is.Not.Null, nameof(session));
|
||||
Assert.That(session.Root, Is.Not.Null, nameof(session.Root));
|
||||
NodeInfo nodeInfo = session.Root.ToNodeInfo();
|
||||
var nodeInfo = session.Root.ToNodeInfo();
|
||||
Assert.That(nodeInfo.IsLeaf, Is.False, "Should not be a leaf node");
|
||||
|
||||
NodeInfo? databaseNode = null;
|
||||
NodeInfo databaseNode = null;
|
||||
|
||||
if (serverNode)
|
||||
{
|
||||
@@ -435,7 +432,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
|
||||
{
|
||||
Assert.NotNull(session);
|
||||
Assert.NotNull(session.Root);
|
||||
NodeInfo nodeInfo = session.Root.ToNodeInfo();
|
||||
var nodeInfo = session.Root.ToNodeInfo();
|
||||
Assert.AreEqual(false, nodeInfo.IsLeaf);
|
||||
Assert.AreEqual(nodeInfo.NodeType, NodeTypes.Database.ToString());
|
||||
Assert.True(nodeInfo.Label.Contains(databaseName));
|
||||
@@ -457,7 +454,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
|
||||
Console.WriteLine($"Session closed uri:{uri}");
|
||||
}
|
||||
|
||||
private async Task ExpandTree(NodeInfo node, ObjectExplorerSession session, StringBuilder? stringBuilder = null, bool verifySystemObjects = false)
|
||||
private async Task ExpandTree(NodeInfo node, ObjectExplorerSession session, StringBuilder stringBuilder = null, bool verifySystemObjects = false)
|
||||
{
|
||||
if (node != null && !node.IsLeaf)
|
||||
{
|
||||
@@ -552,7 +549,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
|
||||
private async Task<bool> VerifyObjectExplorerTest(string databaseName, string testDbPrefix, string queryFileName, string baselineFileName, bool verifySystemObjects = false)
|
||||
{
|
||||
var query = string.IsNullOrEmpty(queryFileName) ? string.Empty : LoadScript(queryFileName);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
var stringBuilder = new StringBuilder();
|
||||
await RunTest(databaseName, query, testDbPrefix, async (testDbName, session) =>
|
||||
{
|
||||
await ExpandServerNodeAndVerifyDatabaseHierachy(testDbName, session, false);
|
||||
@@ -564,7 +561,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
|
||||
|
||||
// Dropped ledger objects have a randomly generated GUID appended to their name when they are deleted
|
||||
// For testing purposes, those guids need to be replaced with a deterministic string
|
||||
actual = Regex.Replace(actual, "[A-Z0-9]{32}", "<<NonDeterministic>>");
|
||||
actual = GetBaselineRegex().Replace(actual, "<<NonDeterministic>>");
|
||||
|
||||
// Write output to a bin directory for easier comparison
|
||||
string assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty;
|
||||
@@ -640,5 +637,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
|
||||
FileInfo inputFile = GetBaseLineFile(fileName);
|
||||
return TestUtilities.ReadTextAndNormalizeLineEndings(inputFile.FullName);
|
||||
}
|
||||
|
||||
[GeneratedRegex("[A-Z0-9]{32}")]
|
||||
private static partial Regex GetBaselineRegex();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user