aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <nikilindsey527@gmail.com>2024-07-09 16:09:15 -0400
committerAdam <nikilindsey527@gmail.com>2024-07-09 16:09:15 -0400
commit86835dd3c6a67e78796eccff707d01af25dac008 (patch)
tree98af9b5d6e308ff73c8214fbf1eda61fb556ec02
parent86c4c9471b1994a3c1290461caa4540cfa5ae183 (diff)
Create PremiereDateComparerTests
Create PremiereDateComparerTests to test PremiereDateComparer functionality.
-rw-r--r--tests/Jellyfin.Server.Implementations.Tests/Sorting/PremiereDateComparerTests.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/Jellyfin.Server.Implementations.Tests/Sorting/PremiereDateComparerTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Sorting/PremiereDateComparerTests.cs
new file mode 100644
index 000000000..153debdfc
--- /dev/null
+++ b/tests/Jellyfin.Server.Implementations.Tests/Sorting/PremiereDateComparerTests.cs
@@ -0,0 +1,45 @@
+using System;
+using Emby.Server.Implementations.Sorting;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities.Movies;
+using Xunit;
+
+namespace Jellyfin.Server.Implementations.Tests.Sorting
+{
+ public class PremiereDateComparerTests
+ {
+ private readonly PremiereDateComparer _cmp = new PremiereDateComparer();
+
+ [Theory]
+ [ClassData(typeof(PremiereDateTestData))]
+ public void PremiereDateCompareTest(BaseItem x, BaseItem y, int expected)
+ {
+ Assert.Equal(expected, _cmp.Compare(x, y));
+ Assert.Equal(-expected, _cmp.Compare(y, x));
+ }
+
+ private sealed class PremiereDateTestData : TheoryData<BaseItem, BaseItem, int>
+ {
+ public PremiereDateTestData()
+ {
+ // Both have premier date
+ Add(
+ new Movie { PremiereDate = new DateTime(2021, 1, 1) },
+ new Movie { PremiereDate = new DateTime(2021, 1, 3) },
+ 0);
+
+ // Only x has premiere date
+ Add(
+ new Movie { PremiereDate = new DateTime(2021, 1, 1) },
+ new Movie { ProductionYear = 2022 },
+ 1);
+
+ // Only x has premiere date, with same year as y
+ Add(
+ new Movie { PremiereDate = new DateTime(2021, 3, 1) },
+ new Movie { ProductionYear = 2021 },
+ 2);
+ }
+ }
+ }
+}