Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Listing07.24.RelationalPatternWithIsOperator.cs - Use the unused hour assignment #725

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading