From 2c4eb6c1f5735d53679d33f0557a6c83b4b9c594 Mon Sep 17 00:00:00 2001 From: Serghei Cebotari Date: Thu, 10 Aug 2023 14:17:08 +0300 Subject: Implement multiple files tests --- Codeforces.Test/Input/1 | 6 ++++++ Codeforces.Test/Input/2 | 6 ++++++ Codeforces.Test/Output/1.a | 5 +++++ Codeforces.Test/Output/2.a | 5 +++++ Codeforces.Test/Tests.cs | 27 +++++++++++++++++++++++---- Codeforces.Test/input.txt | 6 ------ Codeforces.Test/output.txt | 5 ----- 7 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 Codeforces.Test/Input/1 create mode 100644 Codeforces.Test/Input/2 create mode 100644 Codeforces.Test/Output/1.a create mode 100644 Codeforces.Test/Output/2.a delete mode 100644 Codeforces.Test/input.txt delete mode 100644 Codeforces.Test/output.txt diff --git a/Codeforces.Test/Input/1 b/Codeforces.Test/Input/1 new file mode 100644 index 0000000..7b48096 --- /dev/null +++ b/Codeforces.Test/Input/1 @@ -0,0 +1,6 @@ +5 +256 42 +1000 1000 +-1000 1000 +-1000 1000 +20 22 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/1.a b/Codeforces.Test/Output/1.a new file mode 100644 index 0000000..2fea631 --- /dev/null +++ b/Codeforces.Test/Output/1.a @@ -0,0 +1,5 @@ +298 +2000 +0 +0 +42 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 diff --git a/Codeforces.Test/input.txt b/Codeforces.Test/input.txt deleted file mode 100644 index 7b48096..0000000 --- a/Codeforces.Test/input.txt +++ /dev/null @@ -1,6 +0,0 @@ -5 -256 42 -1000 1000 --1000 1000 --1000 1000 -20 22 diff --git a/Codeforces.Test/output.txt b/Codeforces.Test/output.txt deleted file mode 100644 index 2fea631..0000000 --- a/Codeforces.Test/output.txt +++ /dev/null @@ -1,5 +0,0 @@ -298 -2000 -0 -0 -42 -- cgit v1.2.3