-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task2Tests.cs
44 lines (38 loc) · 1.07 KB
/
Task2Tests.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
using adventofcode_2021.Task2;
using System.Collections.Generic;
using System.IO;
using Xunit;
namespace adventofcode_2021.Tests
{
public class Task2Tests
{
[Fact]
public void Task2_IfEmpty_Correct()
{
Assert.Equal(0, Solution.Function(new List<int>()));
}
[Fact]
public void Task2_IfOneElement_Correct()
{
Assert.Equal(0, Solution.Function(new List<int> { 55 }));
}
[Fact]
public void Task2_IfSeveralElements_Correct()
{
Assert.Equal(5, Solution.Function(
new List<int> { 199, 200, 208, 210, 200, 207, 240, 269, 260, 263 }));
}
[Fact]
public void Task2_RealExample_Correct()
{
Assert.Equal(5, Solution.Function(ReadFileAsync(Path.Combine("Task2", "Data.txt"))));
}
private IEnumerable<int> ReadFileAsync(string fileName)
{
foreach (var line in File.ReadLines(fileName))
{
yield return int.Parse(line);
}
}
}
}