-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathAplusBTest.cs
More file actions
41 lines (36 loc) · 1.22 KB
/
AplusBTest.cs
File metadata and controls
41 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
using System;
using System.IO;
using Xunit;
using CourseApp.Module1;
namespace CourseApp.Tests.Module1
{
[Collection("Sequential")]
public class AplusBTest : IDisposable
{
public void Dispose()
{
var standardOut = new StreamWriter(Console.OpenStandardOutput());
standardOut.AutoFlush = true;
var standardIn = new StreamReader(Console.OpenStandardInput());
Console.SetOut(standardOut);
Console.SetIn(standardIn);
}
[Theory]
[InlineData("10 12", "22")]
[InlineData("1 1", "2")]
[InlineData("10000 10000", "20000")]
public void Test1(string input, string expected)
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);
var stringReader = new StringReader(input);
Console.SetIn(stringReader);
// act
AplusB.Calculate();
// assert
var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
Assert.Equal($"{expected}", output[0]);
var standardOutput = new StreamWriter(Console.OpenStandardOutput());
}
}
}