mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-05 01:25:45 -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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user