-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task4Tests.cs
51 lines (45 loc) · 1.23 KB
/
Task4Tests.cs
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
48
49
50
51
using adventofcode_2021.Task4;
using System.Collections.Generic;
using System.IO;
using Xunit;
namespace adventofcode_2021.Tests
{
public class Task4Tests
{
[Fact]
public void Task4_IfEmpty_Correct()
{
Assert.Equal(0, Solution.Function(new List<string>()));
}
[Fact]
public void Task4_IfOneElement_Correct()
{
Assert.Equal(0, Solution.Function(new List<string> { "forward 5" }));
}
[Fact]
public void Task4_IfSeveralElements_Correct()
{
Assert.Equal(900, Solution.Function(
new List<string> {
"forward 5",
"down 5",
"forward 8",
"up 3",
"down 8",
"forward 2"
}));
}
[Fact]
public void Task4_RealExample_Correct()
{
Assert.Equal(900, Solution.Function(ReadFileAsync(Path.Combine("Task4", "Data.txt"))));
}
private IEnumerable<string> ReadFileAsync(string fileName)
{
foreach (var line in File.ReadLines(fileName))
{
yield return line;
}
}
}
}