diff --git a/src/Chapter07.Tests/Listing07.24.Tests.cs b/src/Chapter07.Tests/Listing07.24.Tests.cs index f15071230..121ef61df 100644 --- a/src/Chapter07.Tests/Listing07.24.Tests.cs +++ b/src/Chapter07.Tests/Listing07.24.Tests.cs @@ -42,6 +42,10 @@ public void GetPeriodOfDay_Evening_ReturnsEvening() [TestMethod] public void GetPeriodOfDay_InvalidHour_ReturnsInvalid() { - Assert.ThrowsException(() => PeriodsOfTheDay.GetPeriodOfDay(25)); + int invalidHour = 25; + + var exceptionThrown = Assert.ThrowsException(() => + PeriodsOfTheDay.GetPeriodOfDay(invalidHour)); + Assert.IsTrue(exceptionThrown.Message.StartsWith($"The hour of the day specified ({invalidHour}) is invalid.")); } } diff --git a/src/Chapter07/Listing07.24.RelationalPatternWithIsOperator.cs b/src/Chapter07/Listing07.24.RelationalPatternWithIsOperator.cs index 43b7d4771..1d84e9a19 100644 --- a/src/Chapter07/Listing07.24.RelationalPatternWithIsOperator.cs +++ b/src/Chapter07/Listing07.24.RelationalPatternWithIsOperator.cs @@ -17,7 +17,7 @@ public static string GetPeriodOfDay(int hourOfTheDay) => < 18 => "Afternoon", < 24 => "Evening", int hour => throw new ArgumentOutOfRangeException(nameof(hourOfTheDay), - $"The hour of the day specified is invalid.") + $"The hour of the day specified ({hour}) is invalid.") }; #endregion INCLUDE }