Skip to content

Commit

Permalink
Update Listing07.24.RelationalPatternWithIsOperator.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminMichaelis committed Mar 27, 2024
1 parent 0956625 commit 4ed37c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Chapter07.Tests/Listing07.24.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public void GetPeriodOfDay_Evening_ReturnsEvening()
[TestMethod]
public void GetPeriodOfDay_InvalidHour_ReturnsInvalid()
{
Assert.ThrowsException<ArgumentOutOfRangeException>(() => PeriodsOfTheDay.GetPeriodOfDay(25));
int invalidHour = 25;

var exceptionThrown = Assert.ThrowsException<ArgumentOutOfRangeException>(() =>
PeriodsOfTheDay.GetPeriodOfDay(invalidHour));
Assert.IsTrue(exceptionThrown.Message.StartsWith($"The hour of the day specified ({invalidHour}) is invalid."));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 4ed37c7

Please sign in to comment.