-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSimpleIoTests.cs
More file actions
47 lines (36 loc) · 1.22 KB
/
SimpleIoTests.cs
File metadata and controls
47 lines (36 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using GlyphScriptCompiler.IntegrationTests.TestHelpers;
namespace GlyphScriptCompiler.IntegrationTests;
public class SimpleIoTests : IDisposable
{
private const string TestFilesDirectory = "TestData/SimpleIoExemples";
private readonly ProgramRunner _runner;
public SimpleIoTests(ITestOutputHelper output)
{
_runner = new ProgramRunner(output);
}
private async Task<string> RunProgram(string program, string input)
{
var currentDir = new DirectoryInfo(AppContext.BaseDirectory);
var programPath = Path.Combine(currentDir.FullName, TestFilesDirectory, program);
var output = await _runner.RunProgramAsync(programPath, input);
return output;
}
[Fact]
public async Task ShouldReadAndPrintInt()
{
var output = await RunProgram("readAndPrintInt.gs", "123\n");
var expectedOutput = "123\n";
Assert.Equal(expectedOutput, output);
}
[Fact]
public async Task ShouldReadAndPrintFloat()
{
var output = await RunProgram("readAndPrintFloat.gs", "2.718\n");
var expectedOutput = "2.718000\n";
Assert.Equal(expectedOutput, output);
}
public void Dispose()
{
_runner.Dispose();
}
}