1
0

Implement multiple files tests

This commit is contained in:
Serghei Cebotari 2023-08-10 14:17:08 +03:00
parent ded4e141ee
commit 2c4eb6c1f5
5 changed files with 34 additions and 4 deletions

6
Codeforces.Test/Input/2 Normal file
View File

@ -0,0 +1,6 @@
5
256 42
1000 1000
-1000 1000
-1000 1000
20 22

View File

@ -0,0 +1,5 @@
298
2000
0
0
42

View File

@ -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<object[]>
{
private readonly string inputFolder = @"..\..\..\Input";
public IEnumerator<object[]> 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();
}