From 312508358f0e2d5e2ebd4fbe4fc4316151df6f5d Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Mon, 15 Jan 2018 19:36:29 +1300 Subject: [PATCH] -Tests --- .../Schema/JsonSchemaSpecTests.cs | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaSpecTests.cs b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaSpecTests.cs index 69c31e8d..3fe72029 100644 --- a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaSpecTests.cs +++ b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaSpecTests.cs @@ -24,7 +24,6 @@ #endregion #pragma warning disable 618 -#if !(DNXCORE50) using System; using System.Collections.Generic; using System.IO; @@ -35,9 +34,16 @@ using System.Linq; #endif using System.Reflection; using System.Text; -using NUnit.Framework; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Schema; +#if DNXCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +using TestCaseSource = Xunit.MemberDataAttribute; +#else +using NUnit.Framework; +#endif namespace Newtonsoft.Json.Tests.Schema { @@ -60,7 +66,10 @@ namespace Newtonsoft.Json.Tests.Schema [TestFixture] public class JsonSchemaSpecTests : TestFixtureBase { - [TestCaseSourceAttribute(nameof(GetSpecTestDetails))] +#if DNXCORE50 + [Theory] +#endif + [TestCaseSource(nameof(GetSpecTestDetails))] public void SpecTest(JsonSchemaSpecTest jsonSchemaSpecTest) { JsonSchema s = JsonSchema.Read(jsonSchemaSpecTest.Schema.CreateReader()); @@ -72,13 +81,12 @@ namespace Newtonsoft.Json.Tests.Schema Assert.AreEqual(jsonSchemaSpecTest.IsValid, v, jsonSchemaSpecTest.TestCaseDescription + " - " + jsonSchemaSpecTest.TestDescription + " - errors: " + string.Join(", ", errorMessages)); } - public static IList GetSpecTestDetails() + public static IList GetSpecTestDetails() { IList specTests = new List(); // get test files location relative to the test project dll - string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; - string baseTestPath = Path.Combine(baseDirectory, Path.Combine("Schema", "Specs")); + string baseTestPath = ResolvePath(Path.Combine("Schema", "Specs")); string[] testFiles = Directory.GetFiles(baseTestPath, "*.json", SearchOption.AllDirectories); @@ -115,10 +123,8 @@ namespace Newtonsoft.Json.Tests.Schema && s.TestCaseDescription != "when types includes a schema it should fully validate the schema" && s.TestCaseDescription != "types can include schemas").ToList(); - return specTests; + return specTests.Select(s => new object[] { s }).ToList(); } } } - -#endif #pragma warning restore 618 \ No newline at end of file