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:
David Shiflet
2020-08-05 13:43:14 -04:00
committed by GitHub
parent bf4911795f
commit 839acf67cd
205 changed files with 4146 additions and 4329 deletions

View File

@@ -1,38 +1,39 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
//
// 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 Microsoft.SqlTools.DataProtocol.Contracts.Utilities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Xunit;
using NUnit.Framework;
namespace Microsoft.SqlTools.Hosting.UnitTests.Contracts.Utilities
{
[TestFixture]
public class FlagsStringConverterTests
{
[Fact]
[Test]
public void NullableValueCanBeDeserialized()
{
var jsonObject = JObject.Parse("{\"optionalValue\": [\"First\", \"Second\"]}");
var contract = jsonObject.ToObject<DataContract>();
Assert.NotNull(contract);
Assert.NotNull(contract.OptionalValue);
Assert.Equal(TestFlags.FirstItem | TestFlags.SecondItem, contract.OptionalValue);
Assert.AreEqual(TestFlags.FirstItem | TestFlags.SecondItem, contract.OptionalValue);
}
[Fact]
[Test]
public void RegularValueCanBeDeserialized()
{
var jsonObject = JObject.Parse("{\"Value\": [\"First\", \"Third\"]}");
var contract = jsonObject.ToObject<DataContract>();
Assert.NotNull(contract);
Assert.Equal(TestFlags.FirstItem | TestFlags.ThirdItem, contract.Value);
Assert.AreEqual(TestFlags.FirstItem | TestFlags.ThirdItem, contract.Value);
}
[Fact]
[Test]
public void ExplicitNullCanBeDeserialized()
{
var jsonObject = JObject.Parse("{\"optionalValue\": null}");
@@ -42,7 +43,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.Contracts.Utilities
}
[Flags]
[JsonConverter(typeof(FlagsStringConverter))]
[JsonConverter(typeof(FlagsStringConverter))]
private enum TestFlags
{
[FlagsStringConverter.SerializeValue("First")]
@@ -52,7 +53,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.Contracts.Utilities
SecondItem = 1 << 1,
[FlagsStringConverter.SerializeValue("Third")]
ThirdItem = 1 << 2,
ThirdItem = 1 << 2,
}
private class DataContract