Skip to content

Commit

Permalink
Update PremiereDateComparerTests
Browse files Browse the repository at this point in the history
Add extra tests for edge cases, adjust dummy values for easier debugging
  • Loading branch information
honestlywhoknows committed Jul 10, 2024
1 parent 8933574 commit 0729382
Showing 1 changed file with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,53 @@ private sealed class PremiereDateTestData : TheoryData<BaseItem, BaseItem, int>
{
public PremiereDateTestData()
{
// Both have premier date
// Happy case - Both have premier date
// Expected: x listed first
Add(
new Movie { PremiereDate = new DateTime(2021, 1, 1) },
new Movie { PremiereDate = new DateTime(2021, 1, 3) },
new Movie { PremiereDate = new DateTime(2018, 1, 1) },
new Movie { PremiereDate = new DateTime(2018, 1, 3) },
-1);

// Both have premiere date, but y has invalid date
// Expected: y listed first
Add(
new Movie { PremiereDate = new DateTime(2019, 1, 1) },
new Movie { PremiereDate = new DateTime(03, 1, 1) },
1);

// Only x has premiere date, with earlier year than y
// Expected: x listed first
Add(
new Movie { PremiereDate = new DateTime(2021, 1, 1) },
new Movie { ProductionYear = 2022 },
new Movie { PremiereDate = new DateTime(2020, 1, 1) },
new Movie { ProductionYear = 2021 },
-1);

// Only x has premiere date, with same year as y
// Expected: y listed first
Add(
new Movie { PremiereDate = new DateTime(2021, 1, 2) },
new Movie { ProductionYear = 2021 },
new Movie { PremiereDate = new DateTime(2022, 1, 2) },
new Movie { ProductionYear = 2022 },
1);

// Only x has a premiere date, with later year than y
// Expected: y listed first
Add(
new Movie { PremiereDate = new DateTime(2021, 3, 1) },
new Movie { ProductionYear = 2020 },
new Movie { PremiereDate = new DateTime(2024, 3, 1) },
new Movie { ProductionYear = 2023 },
1);

// Only x has a premiere date, y has an invalid year
// Expected: y listed first
Add(
new Movie { PremiereDate = new DateTime(2025, 1, 1) },
new Movie { ProductionYear = 0 },
1);

// Only x has a premiere date, y has neither date nor year
// Expected: y listed first
Add(
new Movie { PremiereDate = new DateTime(2026, 1, 1) },
new Movie(),
1);
}
}
Expand Down

0 comments on commit 0729382

Please sign in to comment.