-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTask36Tests.cs
59 lines (54 loc) · 1.61 KB
/
Task36Tests.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
52
53
54
55
56
57
58
59
using adventofcode_2021.Task36;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Xunit;
using Xunit.Abstractions;
namespace adventofcode_2021.Tests
{
public class Task36Tests
{
public Task36Tests(ITestOutputHelper output)
{
var converter = new Converter(output);
Console.SetOut(converter);
}
[Fact]
public void Task36_RealExample_Correct()
{
Assert.Equal(3993, Solution.Function(ReadFileAsync(Path.Combine("Task36", "Data.txt"))));
}
private IEnumerable<string> ReadFileAsync(string fileName)
{
foreach (var line in File.ReadLines(fileName))
{
yield return line;
}
}
private class Converter : TextWriter
{
ITestOutputHelper _output;
public Converter(ITestOutputHelper output)
{
_output = output;
}
public override Encoding Encoding
{
get { return Encoding.Default; }
}
public override void WriteLine(string message)
{
_output.WriteLine(message);
}
public override void WriteLine(string format, params object[] args)
{
_output.WriteLine(format, args);
}
public override void Write(char value)
{
throw new NotSupportedException("This text writer only supports WriteLine(string) and WriteLine(string, params object[]).");
}
}
}
}