mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-23 17:24:12 -05:00
Convert most tools service tests to nunit (#1037)
* Remove xunit dependency from testdriver * swap expected/actual as needed * Convert Test.Common to nunit * port hosting unit tests to nunit * port batchparser integration tests to nunit * port testdriver.tests to nunit * fix target to copy dependency * port servicelayer unittests to nunit * more unit test fixes * port integration tests to nunit * fix test method type * try using latest windows build for PRs * reduce test memory use
This commit is contained in:
@@ -7,13 +7,13 @@ using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
using Xunit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
{
|
||||
public class AsyncLockTests
|
||||
{
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task AsyncLockSynchronizesAccess()
|
||||
{
|
||||
AsyncLock asyncLock = new AsyncLock();
|
||||
@@ -21,15 +21,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
Task<IDisposable> lockOne = asyncLock.LockAsync();
|
||||
Task<IDisposable> lockTwo = asyncLock.LockAsync();
|
||||
|
||||
Assert.Equal(TaskStatus.RanToCompletion, lockOne.Status);
|
||||
Assert.Equal(TaskStatus.WaitingForActivation, lockTwo.Status);
|
||||
Assert.AreEqual(TaskStatus.RanToCompletion, lockOne.Status);
|
||||
Assert.AreEqual(TaskStatus.WaitingForActivation, lockTwo.Status);
|
||||
lockOne.Result.Dispose();
|
||||
|
||||
await lockTwo;
|
||||
Assert.Equal(TaskStatus.RanToCompletion, lockTwo.Status);
|
||||
Assert.AreEqual(TaskStatus.RanToCompletion, lockTwo.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void AsyncLockCancelsWhenRequested()
|
||||
{
|
||||
CancellationTokenSource cts = new CancellationTokenSource();
|
||||
@@ -42,8 +42,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
cts.Cancel();
|
||||
lockOne.Result.Dispose();
|
||||
|
||||
Assert.Equal(TaskStatus.RanToCompletion, lockOne.Status);
|
||||
Assert.Equal(TaskStatus.Canceled, lockTwo.Status);
|
||||
Assert.AreEqual(TaskStatus.RanToCompletion, lockOne.Status);
|
||||
Assert.AreEqual(TaskStatus.Canceled, lockTwo.Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
using Xunit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
{
|
||||
public class AsyncQueueTests
|
||||
{
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task AsyncQueueSynchronizesAccess()
|
||||
{
|
||||
ConcurrentBag<int> outputItems = new ConcurrentBag<int>();
|
||||
@@ -53,10 +53,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
|
||||
// At this point, numbers 0 through 299 should be in the outputItems
|
||||
IEnumerable<int> expectedItems = Enumerable.Range(0, 300);
|
||||
Assert.Equal(0, expectedItems.Except(outputItems).Count());
|
||||
Assert.AreEqual(0, expectedItems.Except(outputItems).Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task AsyncQueueSkipsCancelledTasks()
|
||||
{
|
||||
AsyncQueue<int> inputQueue = new AsyncQueue<int>();
|
||||
@@ -71,9 +71,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
await inputQueue.EnqueueAsync(1);
|
||||
|
||||
// Did the second task get the number?
|
||||
Assert.Equal(TaskStatus.Canceled, taskOne.Status);
|
||||
Assert.Equal(TaskStatus.RanToCompletion, taskTwo.Status);
|
||||
Assert.Equal(1, taskTwo.Result);
|
||||
Assert.AreEqual(TaskStatus.Canceled, taskOne.Status);
|
||||
Assert.AreEqual(TaskStatus.RanToCompletion, taskTwo.Status);
|
||||
Assert.AreEqual(1, taskTwo.Result);
|
||||
}
|
||||
|
||||
private async Task ConsumeItems(
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.Hosting.Contracts;
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Capabilities
|
||||
{
|
||||
@@ -16,7 +16,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Capabilities
|
||||
/// </summary>
|
||||
public class Capabilities
|
||||
{
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task TestCapabilities()
|
||||
{
|
||||
Hosting.ServiceHost host = Hosting.ServiceHost.Instance;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Serializers;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Xunit;
|
||||
using NUnit.Framework;
|
||||
using HostingMessage = Microsoft.SqlTools.Hosting.Protocol.Contracts.Message;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
@@ -39,7 +39,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
this.messageSerializer = new JsonRpcMessageSerializer();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void SerializesRequestMessages()
|
||||
{
|
||||
var messageObj =
|
||||
@@ -56,7 +56,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
checkParams: true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void SerializesEventMessages()
|
||||
{
|
||||
var messageObj =
|
||||
@@ -71,7 +71,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
checkParams: true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void SerializesResponseMessages()
|
||||
{
|
||||
var messageObj =
|
||||
@@ -87,7 +87,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
checkResult: true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void SerializesResponseWithErrorMessages()
|
||||
{
|
||||
var messageObj =
|
||||
@@ -114,18 +114,18 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
JToken token = null;
|
||||
|
||||
Assert.True(messageObj.TryGetValue("jsonrpc", out token));
|
||||
Assert.Equal("2.0", token.ToString());
|
||||
Assert.AreEqual("2.0", token.ToString());
|
||||
|
||||
if (checkId)
|
||||
{
|
||||
Assert.True(messageObj.TryGetValue("id", out token));
|
||||
Assert.Equal(MessageId, token.ToString());
|
||||
Assert.AreEqual(MessageId, token.ToString());
|
||||
}
|
||||
|
||||
if (checkMethod)
|
||||
{
|
||||
Assert.True(messageObj.TryGetValue("method", out token));
|
||||
Assert.Equal(MethodName, token.ToString());
|
||||
Assert.AreEqual(MethodName, token.ToString());
|
||||
}
|
||||
|
||||
if (checkError)
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
using Xunit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
{
|
||||
@@ -21,7 +21,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// Test to verify that the logger initialization is generating a valid file
|
||||
/// Verifies that a test log entries is succesfully written to a default log file.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void LoggerDefaultFile()
|
||||
{
|
||||
TestLogger test = new TestLogger()
|
||||
@@ -40,7 +40,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// <summary>
|
||||
/// Test to verify that the logger initialization works using various possibilities.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void LoggerTestInitialization()
|
||||
{
|
||||
int? testNo = 1;
|
||||
@@ -172,7 +172,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// <summary>
|
||||
/// Test to verify that there is no log file created if TracingLevel is set to off.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void LoggerTracingLevelOff()
|
||||
{
|
||||
TestLogger test = new TestLogger()
|
||||
@@ -194,7 +194,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// Verifies that a test log entries logged at Information level are not present in log when tracingLevel
|
||||
/// is set to 'Critical'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void LoggerInformationalNotLoggedWithCriticalTracingLevel()
|
||||
{
|
||||
TestLogger test = new TestLogger()
|
||||
@@ -213,7 +213,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// <summary>
|
||||
/// Test to verify that WriteWithCallstack() method turns on the callstack logging
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void LoggerWithCallstack()
|
||||
{
|
||||
TestLogger test = new TestLogger()
|
||||
@@ -232,7 +232,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// <summary>
|
||||
/// Test to verify that callstack logging is turned on, it does not get logged because tracing level filters them out.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void LoggerWithCallstackFilteredOut()
|
||||
{
|
||||
TestLogger test = new TestLogger()
|
||||
@@ -251,7 +251,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// <summary>
|
||||
/// No TraceSource test to verify that WriteWithCallstack() method turns on the callstack logging
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void LoggerNoTraceSourceWithCallstack()
|
||||
{
|
||||
TestLogger test = new TestLogger()
|
||||
@@ -271,7 +271,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// <summary>
|
||||
/// No TraceSrouce test to verify that callstack logging is turned on, it does not get logged because tracing level filters them out.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void LoggerNoTraceSourceWithCallstackFilteredOut()
|
||||
{
|
||||
TestLogger test = new TestLogger()
|
||||
@@ -292,7 +292,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// Tests to verify that upon changing TracingLevel from Warning To Error,
|
||||
/// after the change, messages of Error type are present in the log and those logged with warning type are not present.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void LoggerTracingLevelFromWarningToError()
|
||||
{
|
||||
// setup the test object
|
||||
@@ -307,7 +307,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// Tests to verify that upon changing TracingLevel from Error To Warning,
|
||||
/// after the change, messages of Warning as well as of Error type are present in the log.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void LoggerTracingLevelFromErrorToWarning()
|
||||
{
|
||||
// setup the test object
|
||||
@@ -322,7 +322,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// When not use TraceSource, test to verify that upon changing TracingLevel from Warning To Error,
|
||||
/// after the change, messages of Error type are present in the log and those logged with warning type are not present.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void LoggerNoTraceSourceTracingLevelFromWarningToError()
|
||||
{
|
||||
// setup the test object
|
||||
@@ -340,7 +340,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// 2nd that after a lot of log entries are written with AutoFlush on, explicitly flushing and closing the Tracing does not increase the file size
|
||||
/// thereby verifying that there was no leftover log entries being left behind to be flushed.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void LoggerAutolFlush()
|
||||
{
|
||||
// setup the test object
|
||||
@@ -365,7 +365,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// When not use TraceSource, test to verify that upon changing TracingLevel from Error To Warning,
|
||||
/// after the change, messages of Warning as well as of Error type are present in the log.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void LoggerNoTraceSourceTracingLevelFromErrorToWarning()
|
||||
{
|
||||
// setup the test object
|
||||
@@ -384,7 +384,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
string oldMessage = @"Old Message with Tracing Level set to Warning";
|
||||
test.LogMessage = oldMessage;
|
||||
// Initially with TracingLevel at Warning, logging of Warning type does not get filtered out.
|
||||
Assert.Equal(SourceLevels.Warning, Logger.TracingLevel);
|
||||
Assert.AreEqual(SourceLevels.Warning, Logger.TracingLevel);
|
||||
{
|
||||
test.EventType = TraceEventType.Warning;
|
||||
test.Write();
|
||||
@@ -405,7 +405,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
|
||||
//Now Update the tracing level to Error. Now logging both of Warning type gets filtered and only Error type should succeed.
|
||||
Logger.TracingLevel = SourceLevels.Error;
|
||||
Assert.Equal(SourceLevels.Error, Logger.TracingLevel);
|
||||
Assert.AreEqual(SourceLevels.Error, Logger.TracingLevel);
|
||||
string newMessage = @"New Message After Tracing Level set to Error";
|
||||
test.LogMessage = newMessage;
|
||||
|
||||
@@ -439,7 +439,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
string oldMessage = @"Old Message with Tracing Level set to Error";
|
||||
test.LogMessage = oldMessage;
|
||||
// Initially with TracingLevel at Error, logging of Warning type gets filtered out.
|
||||
Assert.Equal(SourceLevels.Error, Logger.TracingLevel);
|
||||
Assert.AreEqual(SourceLevels.Error, Logger.TracingLevel);
|
||||
{
|
||||
test.EventType = TraceEventType.Warning;
|
||||
test.Write();
|
||||
@@ -460,7 +460,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
|
||||
//Now Update the tracing level to Warning. Now logging both of Error type and Warning type should succeed.
|
||||
Logger.TracingLevel = SourceLevels.Warning;
|
||||
Assert.Equal(SourceLevels.Warning, Logger.TracingLevel);
|
||||
Assert.AreEqual(SourceLevels.Warning, Logger.TracingLevel);
|
||||
string newMessage = @"New Message After Tracing Level set to Warning";
|
||||
test.LogMessage = newMessage;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using System;
|
||||
using System.Linq;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||
using Xunit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
{
|
||||
@@ -43,7 +43,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// <summary>
|
||||
/// Validate GetLinesInRange with invalid range
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void GetLinesInRangeWithInvalidRangeTest()
|
||||
{
|
||||
ScriptFile scriptFile = GetTestScriptFile();
|
||||
@@ -68,7 +68,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// <summary>
|
||||
/// Validate GetLinesInRange
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void GetLinesInRangeTest()
|
||||
{
|
||||
ScriptFile scriptFile = GetTestScriptFile();
|
||||
@@ -93,7 +93,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
Assert.True(queryLines[1].StartsWith(line), "GetLine text is correct");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void GetOffsetAtPositionTest()
|
||||
{
|
||||
ScriptFile scriptFile = GetTestScriptFile();
|
||||
@@ -105,7 +105,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
Assert.True(position.Line == 2 && position.Column == 5, "Position is at expected location");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void GetRangeBetweenOffsetsTest()
|
||||
{
|
||||
ScriptFile scriptFile = GetTestScriptFile();
|
||||
@@ -115,7 +115,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
Assert.NotNull(range);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanApplySingleLineInsert()
|
||||
{
|
||||
AssertFileChange(
|
||||
@@ -131,7 +131,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanApplySingleLineReplace()
|
||||
{
|
||||
AssertFileChange(
|
||||
@@ -147,7 +147,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanApplySingleLineDelete()
|
||||
{
|
||||
AssertFileChange(
|
||||
@@ -163,7 +163,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanApplyMultiLineInsert()
|
||||
{
|
||||
AssertFileChange(
|
||||
@@ -179,7 +179,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanApplyMultiLineReplace()
|
||||
{
|
||||
AssertFileChange(
|
||||
@@ -195,7 +195,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanApplyMultiLineReplaceWithRemovedLines()
|
||||
{
|
||||
AssertFileChange(
|
||||
@@ -211,7 +211,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanApplyMultiLineDelete()
|
||||
{
|
||||
AssertFileChange(
|
||||
@@ -227,7 +227,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void ThrowsExceptionWithEditOutsideOfRange()
|
||||
{
|
||||
Assert.Throws(
|
||||
@@ -258,7 +258,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
|
||||
// Apply the FileChange and assert the resulting contents
|
||||
fileToChange.ApplyChange(fileChange);
|
||||
Assert.Equal(expectedString, fileToChange.Contents);
|
||||
Assert.AreEqual(expectedString, fileToChange.Contents);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,50 +279,50 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
"Line One\r\nLine Two\r\nLine Three\r\nLine Four\r\nLine Five\r\n");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanGetWholeLine()
|
||||
{
|
||||
string[] lines =
|
||||
scriptFile.GetLinesInRange(
|
||||
new BufferRange(5, 1, 5, 10));
|
||||
|
||||
Assert.Equal(1, lines.Length);
|
||||
Assert.Equal("Line Five", lines[0]);
|
||||
Assert.AreEqual(1, lines.Length);
|
||||
Assert.AreEqual("Line Five", lines[0]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanGetMultipleWholeLines()
|
||||
{
|
||||
string[] lines =
|
||||
scriptFile.GetLinesInRange(
|
||||
new BufferRange(2, 1, 4, 10));
|
||||
|
||||
Assert.Equal(TestStringLines.Skip(1).Take(3), lines);
|
||||
Assert.AreEqual(TestStringLines.Skip(1).Take(3), lines);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanGetSubstringInSingleLine()
|
||||
{
|
||||
string[] lines =
|
||||
scriptFile.GetLinesInRange(
|
||||
new BufferRange(4, 3, 4, 8));
|
||||
|
||||
Assert.Equal(1, lines.Length);
|
||||
Assert.Equal("ne Fo", lines[0]);
|
||||
Assert.AreEqual(1, lines.Length);
|
||||
Assert.AreEqual("ne Fo", lines[0]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanGetEmptySubstringRange()
|
||||
{
|
||||
string[] lines =
|
||||
scriptFile.GetLinesInRange(
|
||||
new BufferRange(4, 3, 4, 3));
|
||||
|
||||
Assert.Equal(1, lines.Length);
|
||||
Assert.Equal("", lines[0]);
|
||||
Assert.AreEqual(1, lines.Length);
|
||||
Assert.AreEqual("", lines[0]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanGetSubstringInMultipleLines()
|
||||
{
|
||||
string[] expectedLines = new string[]
|
||||
@@ -336,10 +336,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
scriptFile.GetLinesInRange(
|
||||
new BufferRange(2, 6, 4, 9));
|
||||
|
||||
Assert.Equal(expectedLines, lines);
|
||||
Assert.AreEqual(expectedLines, lines);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanGetRangeAtLineBoundaries()
|
||||
{
|
||||
string[] expectedLines = new string[]
|
||||
@@ -353,7 +353,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
scriptFile.GetLinesInRange(
|
||||
new BufferRange(2, 9, 4, 1));
|
||||
|
||||
Assert.Equal(expectedLines, lines);
|
||||
Assert.AreEqual(expectedLines, lines);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ First line
|
||||
");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanOffsetByLine()
|
||||
{
|
||||
AssertNewPosition(
|
||||
@@ -385,7 +385,7 @@ First line
|
||||
1, 1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanOffsetByColumn()
|
||||
{
|
||||
AssertNewPosition(
|
||||
@@ -399,7 +399,7 @@ First line
|
||||
2, 2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void ThrowsWhenPositionOutOfRange()
|
||||
{
|
||||
// Less than line range
|
||||
@@ -443,7 +443,7 @@ First line
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanFindBeginningOfLine()
|
||||
{
|
||||
AssertNewPosition(
|
||||
@@ -452,7 +452,7 @@ First line
|
||||
4, 5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanFindEndOfLine()
|
||||
{
|
||||
AssertNewPosition(
|
||||
@@ -461,7 +461,7 @@ First line
|
||||
4, 15);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void CanComposePositionOperations()
|
||||
{
|
||||
AssertNewPosition(
|
||||
@@ -493,8 +493,8 @@ First line
|
||||
originalLine,
|
||||
originalColumn));
|
||||
|
||||
Assert.Equal(expectedLine, newPosition.Line);
|
||||
Assert.Equal(expectedColumn, newPosition.Column);
|
||||
Assert.AreEqual(expectedLine, newPosition.Line);
|
||||
Assert.AreEqual(expectedColumn, newPosition.Column);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.Hosting.Contracts;
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
{
|
||||
public class ServiceHostTests
|
||||
{
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task InitializeResultShouldIncludeTheCharactersThatWouldTriggerTheCompletion()
|
||||
{
|
||||
Hosting.ServiceHost host = Hosting.ServiceHost.Instance;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||
using Xunit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
{
|
||||
@@ -17,7 +17,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
/// The purpose of this test is for code coverage. It's probably better to just
|
||||
/// exclude string resources in the code coverage report than maintain this test.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
[Test]
|
||||
public void SrStringsTest()
|
||||
{
|
||||
var culture = SR.Culture;
|
||||
@@ -208,46 +208,46 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
|
||||
var schemaHierarchyColumnEncryptionKeys = SR.SchemaHierarchy_ColumnEncryptionKeys;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void SrStringsTestWithEnLocalization()
|
||||
{
|
||||
string locale = "en";
|
||||
var args = new string[] { "--locale", locale };
|
||||
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
||||
Assert.Equal(SR.Culture.Name, options.Locale);
|
||||
Assert.Equal(options.Locale, locale);
|
||||
Assert.AreEqual(SR.Culture.Name, options.Locale);
|
||||
Assert.AreEqual(options.Locale, locale);
|
||||
|
||||
var TestLocalizationConstant = SR.TestLocalizationConstant;
|
||||
Assert.Equal(TestLocalizationConstant, "test");
|
||||
Assert.AreEqual("test", TestLocalizationConstant);
|
||||
}
|
||||
|
||||
// [Fact]
|
||||
// [Test]
|
||||
public void SrStringsTestWithEsLocalization()
|
||||
{
|
||||
string locale = "es";
|
||||
var args = new string[] { "--locale", locale };
|
||||
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
||||
Assert.Equal(SR.Culture.Name, options.Locale);
|
||||
Assert.Equal(options.Locale, locale);
|
||||
Assert.AreEqual(SR.Culture.Name, options.Locale);
|
||||
Assert.AreEqual(options.Locale, locale);
|
||||
|
||||
var TestLocalizationConstant = SR.TestLocalizationConstant;
|
||||
Assert.Equal(TestLocalizationConstant, "prueba");
|
||||
Assert.AreEqual("prueba", TestLocalizationConstant);
|
||||
|
||||
// Reset the locale
|
||||
SrStringsTestWithEnLocalization();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void SrStringsTestWithNullLocalization()
|
||||
{
|
||||
SR.Culture = null;
|
||||
var args = new string[] { "" };
|
||||
ServiceLayerCommandOptions options = new ServiceLayerCommandOptions(args);
|
||||
Assert.Null(SR.Culture);
|
||||
Assert.Equal(options.Locale, "");
|
||||
Assert.AreEqual("", options.Locale);
|
||||
|
||||
var TestLocalizationConstant = SR.TestLocalizationConstant;
|
||||
Assert.Equal(TestLocalizationConstant, "test");
|
||||
Assert.AreEqual("test", TestLocalizationConstant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user