2
0

RequestHelpersTests.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using Jellyfin.Api.Helpers;
  4. using Jellyfin.Data.Enums;
  5. using Xunit;
  6. namespace Jellyfin.Api.Tests.Helpers
  7. {
  8. public class RequestHelpersTests
  9. {
  10. [Theory]
  11. [MemberData(nameof(GetOrderBy_Success_TestData))]
  12. public void GetOrderBy_Success(IReadOnlyList<string> sortBy, IReadOnlyList<SortOrder> requestedSortOrder, (string, SortOrder)[] expected)
  13. {
  14. Assert.Equal(expected, RequestHelpers.GetOrderBy(sortBy, requestedSortOrder));
  15. }
  16. public static IEnumerable<object[]> GetOrderBy_Success_TestData()
  17. {
  18. yield return new object[]
  19. {
  20. Array.Empty<string>(),
  21. Array.Empty<SortOrder>(),
  22. Array.Empty<(string, SortOrder)>()
  23. };
  24. yield return new object[]
  25. {
  26. new string[]
  27. {
  28. "IsFavoriteOrLiked",
  29. "Random"
  30. },
  31. Array.Empty<SortOrder>(),
  32. new (string, SortOrder)[]
  33. {
  34. ("IsFavoriteOrLiked", SortOrder.Ascending),
  35. ("Random", SortOrder.Ascending),
  36. }
  37. };
  38. yield return new object[]
  39. {
  40. new string[]
  41. {
  42. "SortName",
  43. "ProductionYear"
  44. },
  45. new SortOrder[]
  46. {
  47. SortOrder.Descending
  48. },
  49. new (string, SortOrder)[]
  50. {
  51. ("SortName", SortOrder.Descending),
  52. ("ProductionYear", SortOrder.Descending),
  53. }
  54. };
  55. }
  56. }
  57. }