From f54e134416c7fd80f699ae2f43fb69dac1ad4b26 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Thu, 27 Oct 2022 12:07:54 -0400 Subject: [PATCH] set day in unit tests --- AOC.Common/AOC.Common.csproj | 4 ++++ AOC.Common/Day.cs | 4 +--- AOC.Common/Extensions.cs | 5 +---- AOC.Test/Test2019.cs | 3 +++ AOC.Test/Test2020.cs | 5 ++++- AOC.Test/Test2021.cs | 7 ++++++- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/AOC.Common/AOC.Common.csproj b/AOC.Common/AOC.Common.csproj index dacc06d..45bf250 100644 --- a/AOC.Common/AOC.Common.csproj +++ b/AOC.Common/AOC.Common.csproj @@ -4,4 +4,8 @@ enable enable + + + + diff --git a/AOC.Common/Day.cs b/AOC.Common/Day.cs index b59df62..6749427 100644 --- a/AOC.Common/Day.cs +++ b/AOC.Common/Day.cs @@ -1,6 +1,4 @@ -using System.Diagnostics; - -namespace AOC.Common; +namespace AOC.Common; public abstract class Day { diff --git a/AOC.Common/Extensions.cs b/AOC.Common/Extensions.cs index 9e31be4..e92046b 100644 --- a/AOC.Common/Extensions.cs +++ b/AOC.Common/Extensions.cs @@ -1,7 +1,4 @@ -using System.Diagnostics; -using System.Numerics; - -namespace AOC.Common; +namespace AOC.Common; public static class Extensions { diff --git a/AOC.Test/Test2019.cs b/AOC.Test/Test2019.cs index 994ed33..8158ba4 100644 --- a/AOC.Test/Test2019.cs +++ b/AOC.Test/Test2019.cs @@ -1,4 +1,5 @@ using AOC2019; + namespace AOC.Test; [TestClass] @@ -34,6 +35,8 @@ public class Test2019 //[DataRow(typeof(Day25), "", "")] public void TestAllDays(Type dayType, string part1, string part2) { + Day.Year = 2019; + var s = Stopwatch.StartNew(); var day = Activator.CreateInstance(dayType) as Day; s.Stop(); diff --git a/AOC.Test/Test2020.cs b/AOC.Test/Test2020.cs index b825c3d..562d5fd 100644 --- a/AOC.Test/Test2020.cs +++ b/AOC.Test/Test2020.cs @@ -1,4 +1,5 @@ using AOC2020; + namespace AOC.Test; [TestClass] @@ -32,6 +33,8 @@ public class Test2020 [DataRow(typeof(Day25), "11707042", "")] public void CheckAllDays(Type dayType, string part1, string part2) { + Day.Year = 2020; + // create day instance var s = Stopwatch.StartNew(); var day = Activator.CreateInstance(dayType) as Day; @@ -55,4 +58,4 @@ public class Test2020 Console.WriteLine($"{s.ScaleMilliseconds()}ms elapsed in part2"); Assert.AreEqual(part2, part2Actual, $"Incorrect answer for Day {day.DayNumber} Part2"); } -} +} \ No newline at end of file diff --git a/AOC.Test/Test2021.cs b/AOC.Test/Test2021.cs index 134a1fc..ec9f390 100644 --- a/AOC.Test/Test2021.cs +++ b/AOC.Test/Test2021.cs @@ -1,4 +1,5 @@ using AOC2021; + namespace AOC.Test; [TestClass] @@ -49,6 +50,8 @@ public class Test2021 [DataRow(typeof(Day25), "417", "")] public void CheckAllDays(Type dayType, string part1, string part2) { + Day.Year = 2021; + var s = Stopwatch.StartNew(); var day = Activator.CreateInstance(dayType) as Day; s.Stop(); @@ -103,7 +106,9 @@ public class Test2021 [DataRow(typeof(Day25), "58", "")] public void CheckTestInputs(Type dayType, string part1, string part2) { + Day.Year = 2021; Day.UseTestInput = true; + var s = Stopwatch.StartNew(); var day = Activator.CreateInstance(dayType) as Day; s.Stop(); @@ -130,4 +135,4 @@ public class Test2021 Console.WriteLine($"{s.ScaleMilliseconds()} ms elapsed"); Assert.AreEqual(part2, part2Actual, $"Incorrect answer for Day {day.DayNumber} Part2"); } -} +} \ No newline at end of file