public void Test16(string d) { string expected = d switch { "1" => "Monday", "2" => "Tuesday", "3" => "Wednesday", "4" => "Thursday", "5" => "Friday", "6" => "Saturday", "7" => "Sunday", _ => "Not valid" }; using (var sw = new StringWriter()) { using (var sr = new StringReader($"{d}")) { Console.SetIn(sr); Console.SetOut(sw); Problem16.Main(); } string result = sw.ToString().Trim(); Assert.AreEqual(expected, result); } }
public void TestInputParsing() { var(rules, myTicket, otherTickets) = Problem16.ParseInput(_firstTestInput); Assert.AreEqual(3, rules.Count()); Assert.AreEqual(4, otherTickets.Count()); Assert.AreEqual(3, myTicket.Fields.Count); Assert.AreEqual("class", rules.First().Name); }
public void TestFindDepartureValueProduct() { string[] testInput = { "class: 0-1 or 4-19", "row: 0-5 or 8-19", "seat: 0-13 or 16-19", "", "your ticket:", "11,12,13", "", "nearby tickets:", "3,9,18", "15,1,5", "5,14,9" }; var(rules, myTicket, otherTickets) = Problem16.ParseInput(testInput); Assert.AreEqual(11, Problem16.FindDepartureValueProduct(rules, myTicket, otherTickets, "row")); Assert.AreEqual(12, Problem16.FindDepartureValueProduct(rules, myTicket, otherTickets, "class")); Assert.AreEqual(13, Problem16.FindDepartureValueProduct(rules, myTicket, otherTickets, "seat")); }
public void Problem16_Return_Result_1366() { long act = Problem16.PowerDigitSum(); Assert.True(act.Equals(1366)); }
public void Problem16_ShouldReturn_1366() { Assert.Equal(Problem16.Problem16Answer(), 1366); }
public void GeneralizedSolution_ExampleValue_ReturnsResult() { var result = Problem16.GeneralizedSolution(15); Assert.AreEqual(26, result); }
public void GeneralizedSolution_ProblemValue_RetrunsResult() { var result = Problem16.GeneralizedSolution(1000); Assert.AreEqual(1366, result); }
public void TestScanErrorRate() { var(rules, myTicket, otherTickets) = Problem16.ParseInput(_firstTestInput); Assert.AreEqual(71, Problem16.FindErrorScanRate(rules, otherTickets.Append(myTicket))); }