Files
advent-of-code-2024/16/ReindeerMaze.Tests/PuzzleSolverTests.cs
T

125 lines
2.9 KiB
C#
Raw Normal View History

2024-12-17 01:24:25 -06:00
namespace ReindeerMaze.Tests;
public class PuzzleSolverTests
{
2024-12-17 22:58:51 -06:00
private async Task<string[]> GetPuzzleInput()
{
return await File.ReadAllLinesAsync(Path.Combine(AppContext.BaseDirectory, "INPUT.txt"));
}
[Test]
public async Task PartOneSolution_WhenCalledWithInput_ItShouldReturnExpectedValue()
{
var input = await GetPuzzleInput();
var result = PuzzleSolver.Solve(input);
await Assert.That(result).IsEqualTo(90460);
}
2024-12-17 01:24:25 -06:00
[Test]
[MethodDataSource(nameof(SolveTestCases))]
public async Task Solve_WhenCalledWithInput_ItShouldReturnExpectedValue(SolveTestCase testCase)
{
2024-12-17 22:58:51 -06:00
var result = PuzzleSolver.Solve(testCase.Input, testCase.IsPart2);
2024-12-17 01:24:25 -06:00
await Assert.That(result).IsEqualTo(testCase.ExpectedValue);
}
public static IEnumerable<Func<SolveTestCase>> SolveTestCases()
{
yield return () => new(
[
"###############",
"#.......#....E#",
"#.#.###.#.###.#",
"#.....#.#...#.#",
"#.###.#####.#.#",
"#.#.#.......#.#",
"#.#.#####.###.#",
"#...........#.#",
"###.#.#####.#.#",
"#...#.....#.#.#",
"#.#.#.###.#.#.#",
"#.....#...#.#.#",
"#.###.#.#.#.#.#",
"#S..#.....#...#",
"###############",
2024-12-17 22:58:51 -06:00
],
false,
2024-12-17 01:24:25 -06:00
7036
);
yield return () => new(
[
"#################",
"#...#...#...#..E#",
"#.#.#.#.#.#.#.#.#",
"#.#.#.#...#...#.#",
"#.#.#.#.###.#.#.#",
"#...#.#.#.....#.#",
"#.#.#.#.#.#####.#",
"#.#...#.#.#.....#",
"#.#.#####.#.###.#",
"#.#.#.......#...#",
"#.#.###.#####.###",
"#.#.#...#.....#.#",
"#.#.#.#####.###.#",
"#.#.#.........#.#",
"#.#.#.#########.#",
"#S#.............#",
"#################",
],
2024-12-17 22:58:51 -06:00
false,
2024-12-17 01:24:25 -06:00
11048
);
2024-12-17 22:58:51 -06:00
yield return () => new(
[
"###############",
"#.......#....E#",
"#.#.###.#.###.#",
"#.....#.#...#.#",
"#.###.#####.#.#",
"#.#.#.......#.#",
"#.#.#####.###.#",
"#...........#.#",
"###.#.#####.#.#",
"#...#.....#.#.#",
"#.#.#.###.#.#.#",
"#.....#...#.#.#",
"#.###.#.#.#.#.#",
"#S..#.....#...#",
"###############",
],
true,
45
);
yield return () => new(
[
"#################",
"#...#...#...#..E#",
"#.#.#.#.#.#.#.#.#",
"#.#.#.#...#...#.#",
"#.#.#.#.###.#.#.#",
"#...#.#.#.....#.#",
"#.#.#.#.#.#####.#",
"#.#...#.#.#.....#",
"#.#.#####.#.###.#",
"#.#.#.......#...#",
"#.#.###.#####.###",
"#.#.#...#.....#.#",
"#.#.#.#####.###.#",
"#.#.#.........#.#",
"#.#.#.#########.#",
"#S#.............#",
"#################",
],
true,
64
);
2024-12-17 01:24:25 -06:00
}
2024-12-17 22:58:51 -06:00
public record SolveTestCase(string[] Input, bool IsPart2, int ExpectedValue);
2024-12-17 01:24:25 -06:00
}