From 2c4eb6c1f5735d53679d33f0557a6c83b4b9c594 Mon Sep 17 00:00:00 2001 From: Serghei Cebotari Date: Thu, 10 Aug 2023 14:17:08 +0300 Subject: [PATCH] Implement multiple files tests --- Codeforces.Test/{input.txt => Input/1} | 0 Codeforces.Test/Input/2 | 6 +++++ Codeforces.Test/{output.txt => Output/1.a} | 0 Codeforces.Test/Output/2.a | 5 ++++ Codeforces.Test/Tests.cs | 27 ++++++++++++++++++---- 5 files changed, 34 insertions(+), 4 deletions(-) rename Codeforces.Test/{input.txt => Input/1} (100%) create mode 100644 Codeforces.Test/Input/2 rename Codeforces.Test/{output.txt => Output/1.a} (100%) create mode 100644 Codeforces.Test/Output/2.a diff --git a/Codeforces.Test/input.txt b/Codeforces.Test/Input/1 similarity index 100% rename from Codeforces.Test/input.txt rename to Codeforces.Test/Input/1 diff --git a/Codeforces.Test/Input/2 b/Codeforces.Test/Input/2 new file mode 100644 index 0000000..7b48096 --- /dev/null +++ b/Codeforces.Test/Input/2 @@ -0,0 +1,6 @@ +5 +256 42 +1000 1000 +-1000 1000 +-1000 1000 +20 22 diff --git a/Codeforces.Test/output.txt b/Codeforces.Test/Output/1.a similarity index 100% rename from Codeforces.Test/output.txt rename to Codeforces.Test/Output/1.a diff --git a/Codeforces.Test/Output/2.a b/Codeforces.Test/Output/2.a new file mode 100644 index 0000000..2fea631 --- /dev/null +++ b/Codeforces.Test/Output/2.a @@ -0,0 +1,5 @@ +298 +2000 +0 +0 +42 diff --git a/Codeforces.Test/Tests.cs b/Codeforces.Test/Tests.cs index d9de594..076b477 100644 --- a/Codeforces.Test/Tests.cs +++ b/Codeforces.Test/Tests.cs @@ -1,17 +1,21 @@ +using System.Collections; + namespace Codeforces.Test; public class Tests { - [Fact] - public void TestIO() + + [Theory] + [ClassData(typeof(FileNameGenerator))] + public void TestIO(string input, string output) { IOTester.Start(); - var lines = File.ReadLines(@"..\..\..\input.txt"); + var lines = File.ReadLines(input); IOTester.SetInput(lines.ToArray()); Program.Main(); - string[] expectedOutput = File.ReadLines(@"..\..\..\output.txt").ToArray(); + string[] expectedOutput = File.ReadLines(output).ToArray(); string[] actualOutput = IOTester.GetOutputLines(); Assert.Equal(expectedOutput.Length, actualOutput.Length); for (int i = 0; i < expectedOutput.Length; i++) @@ -19,4 +23,19 @@ public class Tests Assert.Equal(expectedOutput[i], actualOutput[i]); } } +} +public class FileNameGenerator : IEnumerable +{ + private readonly string inputFolder = @"..\..\..\Input"; + public IEnumerator GetEnumerator() + { + foreach (var input in Directory.GetFiles(inputFolder)) + { + string name = Path.GetFileName(input); + string output = $"..\\..\\..\\Output\\{name}.a"; + yield return new object[] {input, output}; + } + } + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } \ No newline at end of file