mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-15 10:43:30 +01:00
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using Jellyfin.Data.Entities;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Server.Implementations.Item;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Server.Implementations.Tests.Item;
|
||||
|
||||
public class OrderMapperTests
|
||||
{
|
||||
[Fact]
|
||||
public void ShouldReturnMappedOrderForSortingByPremierDate()
|
||||
{
|
||||
var orderFunc = OrderMapper.MapOrderByField(ItemSortBy.PremiereDate, new InternalItemsQuery()).Compile();
|
||||
|
||||
var expectedDate = new DateTime(1, 2, 3);
|
||||
var expectedProductionYearDate = new DateTime(4, 1, 1);
|
||||
|
||||
var entityWithOnlyProductionYear = new BaseItemEntity { Id = Guid.NewGuid(), Type = "Test", ProductionYear = expectedProductionYearDate.Year };
|
||||
var entityWithOnlyPremierDate = new BaseItemEntity { Id = Guid.NewGuid(), Type = "Test", PremiereDate = expectedDate };
|
||||
var entityWithBothPremierDateAndProductionYear = new BaseItemEntity { Id = Guid.NewGuid(), Type = "Test", PremiereDate = expectedDate, ProductionYear = expectedProductionYearDate.Year };
|
||||
var entityWithoutEitherPremierDateOrProductionYear = new BaseItemEntity { Id = Guid.NewGuid(), Type = "Test" };
|
||||
|
||||
var resultWithOnlyProductionYear = orderFunc(entityWithOnlyProductionYear);
|
||||
var resultWithOnlyPremierDate = orderFunc(entityWithOnlyPremierDate);
|
||||
var resultWithBothPremierDateAndProductionYear = orderFunc(entityWithBothPremierDateAndProductionYear);
|
||||
var resultWithoutEitherPremierDateOrProductionYear = orderFunc(entityWithoutEitherPremierDateOrProductionYear);
|
||||
|
||||
Assert.Equal(resultWithOnlyProductionYear, expectedProductionYearDate);
|
||||
Assert.Equal(resultWithOnlyPremierDate, expectedDate);
|
||||
Assert.Equal(resultWithBothPremierDateAndProductionYear, expectedDate);
|
||||
Assert.Null(resultWithoutEitherPremierDateOrProductionYear);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user