|
|
|
@ -8,13 +8,8 @@ namespace ErsatzTV.Core.Tests.Scheduling; |
|
|
|
[TestFixture] |
|
|
|
[TestFixture] |
|
|
|
public class ChronologicalContentTests |
|
|
|
public class ChronologicalContentTests |
|
|
|
{ |
|
|
|
{ |
|
|
|
[SetUp] |
|
|
|
|
|
|
|
public void SetUp() => _cancellationToken = new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private CancellationToken _cancellationToken; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
[Test] |
|
|
|
public void Episodes_Should_Sort_By_Aired() |
|
|
|
public void Episodes_Should_Sort_By_ReleaseDate() |
|
|
|
{ |
|
|
|
{ |
|
|
|
List<MediaItem> contents = Episodes(10); |
|
|
|
List<MediaItem> contents = Episodes(10); |
|
|
|
var state = new CollectionEnumeratorState(); |
|
|
|
var state = new CollectionEnumeratorState(); |
|
|
|
@ -29,6 +24,22 @@ public class ChronologicalContentTests |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void OtherVideos_Should_Sort_By_ReleaseDate() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
List<MediaItem> contents = OtherVideos(10); |
|
|
|
|
|
|
|
var state = new CollectionEnumeratorState(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var chronologicalContent = new ChronologicalMediaCollectionEnumerator(contents, state); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 1; i <= 10; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
chronologicalContent.Current.IsSome.ShouldBeTrue(); |
|
|
|
|
|
|
|
chronologicalContent.Current.Map(x => x.Id).IfNone(-1).ShouldBe(10 - i); |
|
|
|
|
|
|
|
chronologicalContent.MoveNext(Option<DateTimeOffset>.None); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
[Test] |
|
|
|
public void State_Index_Should_Increment() |
|
|
|
public void State_Index_Should_Increment() |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -77,14 +88,31 @@ public class ChronologicalContentTests |
|
|
|
Range(1, count).Map(i => (MediaItem)new Episode |
|
|
|
Range(1, count).Map(i => (MediaItem)new Episode |
|
|
|
{ |
|
|
|
{ |
|
|
|
Id = i, |
|
|
|
Id = i, |
|
|
|
EpisodeMetadata = new List<EpisodeMetadata> |
|
|
|
EpisodeMetadata = |
|
|
|
{ |
|
|
|
[ |
|
|
|
new() |
|
|
|
new EpisodeMetadata |
|
|
|
{ |
|
|
|
{ |
|
|
|
ReleaseDate = new DateTime(2020, 1, i), |
|
|
|
ReleaseDate = new DateTime(2020, 1, i), |
|
|
|
EpisodeNumber = 20 - i |
|
|
|
EpisodeNumber = 20 - i |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.Reverse() |
|
|
|
|
|
|
|
.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<MediaItem> OtherVideos(int count) => |
|
|
|
|
|
|
|
Range(1, count).Map(i => (MediaItem)new OtherVideo |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// ids need to count down because fallback sorting is by id
|
|
|
|
|
|
|
|
// and we need the test to fail when these are sorted by id
|
|
|
|
|
|
|
|
Id = count - i, |
|
|
|
|
|
|
|
OtherVideoMetadata = |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
new OtherVideoMetadata |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ReleaseDate = new DateTime(2020, 1, i) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
}) |
|
|
|
}) |
|
|
|
.Reverse() |
|
|
|
.Reverse() |
|
|
|
.ToList(); |
|
|
|
.ToList(); |
|
|
|
|