aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaus Vium <cvium@users.noreply.github.com>2021-01-24 19:04:12 +0100
committerGitHub <noreply@github.com>2021-01-24 19:04:12 +0100
commit98a4e1b8402c37703344113e302167b5e2721d5f (patch)
tree8e031bfed0739a8d1859cebc54b3c0f65c261ec4 /tests
parent3806cc5b3ff3633d66d96e990fd26c7db8365cd5 (diff)
parentf6b293203aac0dd57c93ca9e77b8441a2c1918fd (diff)
Merge pull request #5095 from Bond-009/sortorder
Diffstat (limited to 'tests')
-rw-r--r--tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs b/tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs
new file mode 100644
index 000000000..606041c7f
--- /dev/null
+++ b/tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using Jellyfin.Api.Helpers;
+using Jellyfin.Data.Enums;
+using Xunit;
+
+namespace Jellyfin.Api.Tests.Helpers
+{
+ public class RequestHelpersTests
+ {
+ [Theory]
+ [MemberData(nameof(GetOrderBy_Success_TestData))]
+ public void GetOrderBy_Success(IReadOnlyList<string> sortBy, IReadOnlyList<SortOrder> requestedSortOrder, (string, SortOrder)[] expected)
+ {
+ Assert.Equal(expected, RequestHelpers.GetOrderBy(sortBy, requestedSortOrder));
+ }
+
+ public static IEnumerable<object[]> GetOrderBy_Success_TestData()
+ {
+ yield return new object[]
+ {
+ Array.Empty<string>(),
+ Array.Empty<SortOrder>(),
+ Array.Empty<(string, SortOrder)>()
+ };
+ yield return new object[]
+ {
+ new string[]
+ {
+ "IsFavoriteOrLiked",
+ "Random"
+ },
+ Array.Empty<SortOrder>(),
+ new (string, SortOrder)[]
+ {
+ ("IsFavoriteOrLiked", SortOrder.Ascending),
+ ("Random", SortOrder.Ascending),
+ }
+ };
+ yield return new object[]
+ {
+ new string[]
+ {
+ "SortName",
+ "ProductionYear"
+ },
+ new SortOrder[]
+ {
+ SortOrder.Descending
+ },
+ new (string, SortOrder)[]
+ {
+ ("SortName", SortOrder.Descending),
+ ("ProductionYear", SortOrder.Descending),
+ }
+ };
+ }
+ }
+}