From f537c83682338f5b7d947782e6c4afa8bbdaf926 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Wed, 13 Sep 2023 15:14:06 +0200 Subject: [PATCH] Remove obsolete tests --- Exercism.TestRunner.CSharp.sln | 7 +- ....TestRunner.CSharp.IntegrationTests.csproj | 28 --- .../NormalizationExtensions.cs | 17 -- .../TestRun.cs | 11 - .../TestRunResultReader.cs | 90 -------- .../TestRunnerTests.cs | 203 ------------------ .../TestSolution.cs | 17 -- .../TestSolutionRunner.cs | 26 --- 8 files changed, 1 insertion(+), 398 deletions(-) delete mode 100644 test/Exercism.TestRunner.CSharp.IntegrationTests/Exercism.TestRunner.CSharp.IntegrationTests.csproj delete mode 100644 test/Exercism.TestRunner.CSharp.IntegrationTests/NormalizationExtensions.cs delete mode 100644 test/Exercism.TestRunner.CSharp.IntegrationTests/TestRun.cs delete mode 100644 test/Exercism.TestRunner.CSharp.IntegrationTests/TestRunResultReader.cs delete mode 100644 test/Exercism.TestRunner.CSharp.IntegrationTests/TestRunnerTests.cs delete mode 100644 test/Exercism.TestRunner.CSharp.IntegrationTests/TestSolution.cs delete mode 100644 test/Exercism.TestRunner.CSharp.IntegrationTests/TestSolutionRunner.cs diff --git a/Exercism.TestRunner.CSharp.sln b/Exercism.TestRunner.CSharp.sln index ebeec1d..d672577 100644 --- a/Exercism.TestRunner.CSharp.sln +++ b/Exercism.TestRunner.CSharp.sln @@ -1,7 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercism.TestRunner.CSharp.IntegrationTests", "test\Exercism.TestRunner.CSharp.IntegrationTests\Exercism.TestRunner.CSharp.IntegrationTests.csproj", "{89F04548-B730-4F84-AC39-5B8C6A47CA35}" -EndProject +# Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercism.TestRunner.CSharp", "src\Exercism.TestRunner.CSharp\Exercism.TestRunner.CSharp.csproj", "{76037C86-908F-4C18-BDBE-1C1CAFF0CB65}" EndProject Global @@ -10,10 +9,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {89F04548-B730-4F84-AC39-5B8C6A47CA35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {89F04548-B730-4F84-AC39-5B8C6A47CA35}.Debug|Any CPU.Build.0 = Debug|Any CPU - {89F04548-B730-4F84-AC39-5B8C6A47CA35}.Release|Any CPU.ActiveCfg = Release|Any CPU - {89F04548-B730-4F84-AC39-5B8C6A47CA35}.Release|Any CPU.Build.0 = Release|Any CPU {76037C86-908F-4C18-BDBE-1C1CAFF0CB65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {76037C86-908F-4C18-BDBE-1C1CAFF0CB65}.Debug|Any CPU.Build.0 = Debug|Any CPU {76037C86-908F-4C18-BDBE-1C1CAFF0CB65}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/test/Exercism.TestRunner.CSharp.IntegrationTests/Exercism.TestRunner.CSharp.IntegrationTests.csproj b/test/Exercism.TestRunner.CSharp.IntegrationTests/Exercism.TestRunner.CSharp.IntegrationTests.csproj deleted file mode 100644 index 690d636..0000000 --- a/test/Exercism.TestRunner.CSharp.IntegrationTests/Exercism.TestRunner.CSharp.IntegrationTests.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - net7.0 - false - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/Exercism.TestRunner.CSharp.IntegrationTests/NormalizationExtensions.cs b/test/Exercism.TestRunner.CSharp.IntegrationTests/NormalizationExtensions.cs deleted file mode 100644 index 865222a..0000000 --- a/test/Exercism.TestRunner.CSharp.IntegrationTests/NormalizationExtensions.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; - -namespace Exercism.TestRunner.CSharp.IntegrationTests -{ - internal static class NormalizationExtensions - { - public static string NormalizeJson(this string json) => - JsonConvert.SerializeObject(JsonConvert.DeserializeObject(json), Formatting.None, CreateJsonSerializerSettings()).NormalizeNewlines(); - - private static string NormalizeNewlines(this string json) => - json.Replace("\r\n", "\n"); - - private static JsonSerializerSettings CreateJsonSerializerSettings() => - new() { ContractResolver = new DefaultContractResolver { NamingStrategy = new SnakeCaseNamingStrategy() } }; - } -} \ No newline at end of file diff --git a/test/Exercism.TestRunner.CSharp.IntegrationTests/TestRun.cs b/test/Exercism.TestRunner.CSharp.IntegrationTests/TestRun.cs deleted file mode 100644 index 49ef019..0000000 --- a/test/Exercism.TestRunner.CSharp.IntegrationTests/TestRun.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Exercism.TestRunner.CSharp.IntegrationTests -{ - internal class TestRun - { - public string Expected { get; } - public string Actual { get; } - - public TestRun(string expected, string actual) => - (Expected, Actual) = (expected, actual); - } -} \ No newline at end of file diff --git a/test/Exercism.TestRunner.CSharp.IntegrationTests/TestRunResultReader.cs b/test/Exercism.TestRunner.CSharp.IntegrationTests/TestRunResultReader.cs deleted file mode 100644 index 1596a2a..0000000 --- a/test/Exercism.TestRunner.CSharp.IntegrationTests/TestRunResultReader.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.IO; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Exercism.TestRunner.CSharp.IntegrationTests -{ - internal static class TestRunResultReader - { - public static string ReadActual(TestSolution solution) => - ReadTestRunResult(solution, "results.json"); - - public static string ReadExpected(TestSolution solution) => - ReadTestRunResult(solution, "expected_results.json"); - - private static string ReadTestRunResult(TestSolution solution, string fileName) - { - var testRunResult = DeserializeTestRunResult(solution, fileName); - NormalizeTestRunResult(testRunResult); - - return JsonSerializer.Serialize(testRunResult, CreateJsonSerializerOptions()); - } - - private static TestRunResult DeserializeTestRunResult(TestSolution solution, string fileName) => - JsonSerializer.Deserialize(ReadFile(solution, fileName), CreateJsonSerializerOptions()); - - private static string ReadFile(TestSolution solution, string fileName) => - File.ReadAllText(Path.Combine(solution.DirectoryFullPath, fileName)); - - private static void NormalizeTestRunResult(TestRunResult testRunResult) - { - if (testRunResult.Tests == null) - return; - - static int Comparison(TestResult x, TestResult y) => string.Compare(x.Name, y.Name, StringComparison.Ordinal); - Array.Sort(testRunResult.Tests, Comparison); - } - - private static JsonSerializerOptions CreateJsonSerializerOptions() - { - var options = new JsonSerializerOptions - { - DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, - PropertyNamingPolicy = null - }; - options.Converters.Add(new JsonStringEnumConverter()); - return options; - } - - private enum TestStatus - { - Pass, - Fail, - Error - } - - private struct TestRunResult - { - [JsonPropertyName("version")] - public int Version { get; set; } - - [JsonPropertyName("status")] - public TestStatus Status { get; set; } - - [JsonPropertyName("message")] - public string Message { get; set; } - - [JsonPropertyName("tests")] - public TestResult[] Tests { get; set; } - } - - private struct TestResult - { - [JsonPropertyName("status")] - public TestStatus Status { get; set; } - - [JsonPropertyName("message")] - public string Message { get; set; } - - [JsonPropertyName("name")] - public string Name { get; set; } - - [JsonPropertyName("task_id")] - public int? TaskId { get; set; } - - [JsonPropertyName("output")] - public string Output { get; set; } - } - } -} \ No newline at end of file diff --git a/test/Exercism.TestRunner.CSharp.IntegrationTests/TestRunnerTests.cs b/test/Exercism.TestRunner.CSharp.IntegrationTests/TestRunnerTests.cs deleted file mode 100644 index e032fbd..0000000 --- a/test/Exercism.TestRunner.CSharp.IntegrationTests/TestRunnerTests.cs +++ /dev/null @@ -1,203 +0,0 @@ -using Xunit; - -namespace Exercism.TestRunner.CSharp.IntegrationTests -{ - public class TestRunnerTests - { - [Fact] - public void MultipleCompileErrors() - { - var testRun = TestSolutionRunner.Run("MultipleCompileErrors"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void MultipleTestClassesWithAllPasses() - { - var testRun = TestSolutionRunner.Run("MultipleTestClassesWithAllPasses"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void MultipleTestsWithAllPasses() - { - var testRun = TestSolutionRunner.Run("MultipleTestsWithAllPasses"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void MultipleTestsWithMultipleFails() - { - var testRun = TestSolutionRunner.Run("MultipleTestsWithMultipleFails"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void MultipleTestsWithSingleFail() - { - var testRun = TestSolutionRunner.Run("MultipleTestsWithSingleFail"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void MultipleTestsWithTestOutput() - { - var testRun = TestSolutionRunner.Run("MultipleTestsWithTestOutput"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void MultipleTestsWithTestOutputExceedingLimit() - { - var testRun = TestSolutionRunner.Run("MultipleTestsWithTestOutputExceedingLimit"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void NoTests() - { - var testRun = TestSolutionRunner.Run("NoTests"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void NotImplemented() - { - var testRun = TestSolutionRunner.Run("NotImplemented"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void SingleCompileError() - { - var testRun = TestSolutionRunner.Run("SingleCompileError"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void SingleTestThatFails() - { - var testRun = TestSolutionRunner.Run("SingleTestThatFails"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void SingleTestThatPasses() - { - var testRun = TestSolutionRunner.Run("SingleTestThatPasses"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void SingleTestThatPassesWithDifferentSlug() - { - var testRun = TestSolutionRunner.Run("SingleTestThatPassesWithDifferentSlug", "Foo"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void TestsInDifferentFormats() - { - var testRun = TestSolutionRunner.Run("TestsInDifferentFormats"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void NoTasks() - { - var testRun = TestSolutionRunner.Run("NoTasks"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void AllTestsWithTask() - { - var testRun = TestSolutionRunner.Run("AllTestsWithTask"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void SomeTestsWithTask() - { - var testRun = TestSolutionRunner.Run("SomeTestsWithTask"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void WithExample() - { - var testRun = TestSolutionRunner.Run("WithExample"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void WithConstructor() - { - var testRun = TestSolutionRunner.Run("WithConstructor"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void WithDisposable() - { - var testRun = TestSolutionRunner.Run("WithDisposable"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void UseCultureAttribute() - { - var testRun = TestSolutionRunner.Run("UseCultureAttribute"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void DownloadedSolution() - { - var testRun = TestSolutionRunner.Run("DownloadedSolution"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void CompileErrorWithoutLocation() - { - var testRun = TestSolutionRunner.Run("CompileErrorWithoutLocation"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void WithNonTestClasses() - { - var testRun = TestSolutionRunner.Run("WithNonTestClasses"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void EditorFiles() - { - var testRun = TestSolutionRunner.Run("EditorFiles"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void WithPrivateDisposableClasses() - { - var testRun = TestSolutionRunner.Run("WithPrivateDisposableClasses"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void UseTimeZones() - { - var testRun = TestSolutionRunner.Run("UseTimeZones"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - - [Fact] - public void DifferentTypesOfTests() - { - var testRun = TestSolutionRunner.Run("DifferentTypesOfTests"); - Assert.Equal(testRun.Expected, testRun.Actual); - } - } -} \ No newline at end of file diff --git a/test/Exercism.TestRunner.CSharp.IntegrationTests/TestSolution.cs b/test/Exercism.TestRunner.CSharp.IntegrationTests/TestSolution.cs deleted file mode 100644 index d7b0b8b..0000000 --- a/test/Exercism.TestRunner.CSharp.IntegrationTests/TestSolution.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.IO; - -namespace Exercism.TestRunner.CSharp.IntegrationTests -{ - public class TestSolution - { - public string Slug { get; } - public string Directory { get; } - public string DirectoryFullPath => Path.GetFullPath(Path.Combine(Path.GetDirectoryName(typeof(TestSolution).Assembly.Location)!, "tests", Directory)); - - public TestSolution(string slug, string directory) - { - Slug = slug; - Directory = directory; - } - } -} \ No newline at end of file diff --git a/test/Exercism.TestRunner.CSharp.IntegrationTests/TestSolutionRunner.cs b/test/Exercism.TestRunner.CSharp.IntegrationTests/TestSolutionRunner.cs deleted file mode 100644 index 813914d..0000000 --- a/test/Exercism.TestRunner.CSharp.IntegrationTests/TestSolutionRunner.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Diagnostics; - -namespace Exercism.TestRunner.CSharp.IntegrationTests -{ - internal static class TestSolutionRunner - { - public static TestRun Run(string directory, string slug = "Fake") - { - var testSolution = new TestSolution(slug, directory); - - RunTestRunner(testSolution); - return CreateTestRun(testSolution); - } - - private static void RunTestRunner(TestSolution testSolution) => - Program.Main(new[] { testSolution.Slug, testSolution.DirectoryFullPath, testSolution.DirectoryFullPath }); - - private static TestRun CreateTestRun(TestSolution solution) - { - var actualTestRunResult = TestRunResultReader.ReadActual(solution); - var expectedTestRunResult = TestRunResultReader.ReadExpected(solution); - - return new TestRun(expectedTestRunResult, actualTestRunResult); - } - } -} \ No newline at end of file