about summary refs log tree commit diff
path: root/aoc2021.test
diff options
context:
space:
mode:
Diffstat (limited to 'aoc2021.test')
-rw-r--r--aoc2021.test/DayTests.cs32
-rw-r--r--aoc2021.test/aoc2021.test.csproj26
2 files changed, 58 insertions, 0 deletions
diff --git a/aoc2021.test/DayTests.cs b/aoc2021.test/DayTests.cs
new file mode 100644
index 0000000..0de9c22
--- /dev/null
+++ b/aoc2021.test/DayTests.cs
@@ -0,0 +1,32 @@
+namespace aoc2021.test;
+
+[TestClass]
+public class DayTests
+{
+    [DataTestMethod]
+    [DataRow(typeof(Day01), "", "")]
+    public void CheckAllDays(Type dayType, string part1, string part2)
+    {
+        var s = Stopwatch.StartNew();
+        var day = Activator.CreateInstance(dayType) as Day;
+        s.Stop();
+        Assert.IsNotNull(day, "failed to instantiate day object");
+        Console.WriteLine($"{s.ScaleMilliseconds()} ms elapsed in constructor");
+
+        // part 1
+        s.Reset();
+        s.Start();
+        var part1Actual = day.Part1();
+        s.Stop();
+        Console.WriteLine($"{s.ScaleMilliseconds()} ms elapsed in part1");
+        Assert.AreEqual(part1, part1Actual, $"Incorrect answer for Day {day.DayNumber} Part1");
+
+        // part 2
+        s.Reset();
+        s.Start();
+        var part2Actual = day.Part2();
+        s.Stop();
+        Console.WriteLine($"{s.ScaleMilliseconds()} ms elapsed in part2");
+        Assert.AreEqual(part2, part2Actual, $"Incorrect answer for Day {day.DayNumber} Part2");
+    }
+}
diff --git a/aoc2021.test/aoc2021.test.csproj b/aoc2021.test/aoc2021.test.csproj
new file mode 100644
index 0000000..fa31f2b
--- /dev/null
+++ b/aoc2021.test/aoc2021.test.csproj
@@ -0,0 +1,26 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+	<TargetFramework>net6.0</TargetFramework>
+	<ImplicitUsings>enable</ImplicitUsings>
+	<Nullable>enable</Nullable>
+	<IsPackable>false</IsPackable>
+  </PropertyGroup>
+
+  <ItemGroup>
+	<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
+	<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
+	<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
+	<PackageReference Include="coverlet.collector" Version="3.1.0" />
+  </ItemGroup>
+
+  <ItemGroup>
+	<ProjectReference Include="..\aoc2021\aoc2021.csproj" />
+  </ItemGroup>
+
+  <ItemGroup>
+	<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting"/>
+	<Using Include="System.Diagnostics"/>
+  </ItemGroup>
+
+</Project>