|
|
|
@ -3,8 +3,10 @@ using ErsatzTV.Core.Domain.Filler; |
|
|
|
using ErsatzTV.Core.Interfaces.Scheduling; |
|
|
|
using ErsatzTV.Core.Interfaces.Scheduling; |
|
|
|
using ErsatzTV.Core.Scheduling; |
|
|
|
using ErsatzTV.Core.Scheduling; |
|
|
|
using FluentAssertions; |
|
|
|
using FluentAssertions; |
|
|
|
|
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Moq; |
|
|
|
using Moq; |
|
|
|
using NUnit.Framework; |
|
|
|
using NUnit.Framework; |
|
|
|
|
|
|
|
using Serilog; |
|
|
|
|
|
|
|
|
|
|
|
namespace ErsatzTV.Core.Tests.Scheduling; |
|
|
|
namespace ErsatzTV.Core.Tests.Scheduling; |
|
|
|
|
|
|
|
|
|
|
|
@ -222,7 +224,7 @@ public class PlayoutModeSchedulerBaseTests : SchedulerTestBase |
|
|
|
|
|
|
|
|
|
|
|
PlayoutBuilderState startState = StartState(scheduleItemsEnumerator); |
|
|
|
PlayoutBuilderState startState = StartState(scheduleItemsEnumerator); |
|
|
|
|
|
|
|
|
|
|
|
List<PlayoutItem> playoutItems = PlayoutModeSchedulerBase<ProgramScheduleItem> |
|
|
|
List<PlayoutItem> playoutItems = Scheduler() |
|
|
|
.AddFiller( |
|
|
|
.AddFiller( |
|
|
|
startState, |
|
|
|
startState, |
|
|
|
CollectionEnumerators(scheduleItem, enumerator), |
|
|
|
CollectionEnumerators(scheduleItem, enumerator), |
|
|
|
@ -273,7 +275,7 @@ public class PlayoutModeSchedulerBaseTests : SchedulerTestBase |
|
|
|
// too lazy to make another enumerator for the filler that we don't want
|
|
|
|
// too lazy to make another enumerator for the filler that we don't want
|
|
|
|
enumerators.Add(CollectionKey.ForFillerPreset(scheduleItem.MidRollFiller), enumerator); |
|
|
|
enumerators.Add(CollectionKey.ForFillerPreset(scheduleItem.MidRollFiller), enumerator); |
|
|
|
|
|
|
|
|
|
|
|
List<PlayoutItem> playoutItems = PlayoutModeSchedulerBase<ProgramScheduleItem> |
|
|
|
List<PlayoutItem> playoutItems = Scheduler() |
|
|
|
.AddFiller( |
|
|
|
.AddFiller( |
|
|
|
startState, |
|
|
|
startState, |
|
|
|
enumerators, |
|
|
|
enumerators, |
|
|
|
@ -283,6 +285,77 @@ public class PlayoutModeSchedulerBaseTests : SchedulerTestBase |
|
|
|
|
|
|
|
|
|
|
|
playoutItems.Count.Should().Be(1); |
|
|
|
playoutItems.Count.Should().Be(1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void Should_Schedule_Mid_Roll_Count_Filler_Correctly() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Collection collectionOne = TwoItemCollection(1, 2, TimeSpan.FromHours(1)); |
|
|
|
|
|
|
|
Collection collectionTwo = TwoItemCollection(3, 4, TimeSpan.FromMinutes(5)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var scheduleItem = new ProgramScheduleItemOne |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Id = 1, |
|
|
|
|
|
|
|
Index = 1, |
|
|
|
|
|
|
|
Collection = collectionOne, |
|
|
|
|
|
|
|
CollectionId = collectionOne.Id, |
|
|
|
|
|
|
|
StartTime = null, |
|
|
|
|
|
|
|
PlaybackOrder = PlaybackOrder.Chronological, |
|
|
|
|
|
|
|
TailFiller = null, |
|
|
|
|
|
|
|
FallbackFiller = null, |
|
|
|
|
|
|
|
MidRollFiller = new FillerPreset |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
FillerKind = FillerKind.MidRoll, |
|
|
|
|
|
|
|
FillerMode = FillerMode.Count, |
|
|
|
|
|
|
|
PadToNearestMinute = 60, // this should be ignored
|
|
|
|
|
|
|
|
Count = 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var scheduleItemsEnumerator = new OrderedScheduleItemsEnumerator( |
|
|
|
|
|
|
|
new List<ProgramScheduleItem> { scheduleItem }, |
|
|
|
|
|
|
|
new CollectionEnumeratorState()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var enumerator = new ChronologicalMediaCollectionEnumerator( |
|
|
|
|
|
|
|
collectionOne.MediaItems, |
|
|
|
|
|
|
|
new CollectionEnumeratorState()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fillerEnumerator = new ChronologicalMediaCollectionEnumerator( |
|
|
|
|
|
|
|
collectionTwo.MediaItems, |
|
|
|
|
|
|
|
new CollectionEnumeratorState()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PlayoutBuilderState startState = StartState(scheduleItemsEnumerator); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<CollectionKey, IMediaCollectionEnumerator> enumerators = CollectionEnumerators( |
|
|
|
|
|
|
|
scheduleItem, |
|
|
|
|
|
|
|
enumerator); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enumerators.Add(CollectionKey.ForFillerPreset(scheduleItem.MidRollFiller), fillerEnumerator); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<PlayoutItem> playoutItems = Scheduler() |
|
|
|
|
|
|
|
.AddFiller( |
|
|
|
|
|
|
|
startState, |
|
|
|
|
|
|
|
enumerators, |
|
|
|
|
|
|
|
scheduleItem, |
|
|
|
|
|
|
|
new PlayoutItem |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
MediaItemId = 1, |
|
|
|
|
|
|
|
Start = startState.CurrentTime.UtcDateTime, |
|
|
|
|
|
|
|
Finish = startState.CurrentTime.AddHours(1).UtcDateTime |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
new List<MediaChapter> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
new() { StartTime = TimeSpan.Zero, EndTime = TimeSpan.FromMinutes(6) }, |
|
|
|
|
|
|
|
new() { StartTime = TimeSpan.FromMinutes(6), EndTime = TimeSpan.FromMinutes(60) } |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
playoutItems.Count.Should().Be(3); |
|
|
|
|
|
|
|
playoutItems[0].MediaItemId.Should().Be(1); |
|
|
|
|
|
|
|
playoutItems[0].StartOffset.Should().Be(startState.CurrentTime); |
|
|
|
|
|
|
|
playoutItems[1].MediaItemId.Should().Be(3); |
|
|
|
|
|
|
|
playoutItems[1].StartOffset.Should().Be(startState.CurrentTime + TimeSpan.FromMinutes(6)); |
|
|
|
|
|
|
|
playoutItems[2].MediaItemId.Should().Be(1); |
|
|
|
|
|
|
|
playoutItems[2].StartOffset.Should().Be(startState.CurrentTime + TimeSpan.FromMinutes(11)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[TestFixture] |
|
|
|
[TestFixture] |
|
|
|
@ -324,4 +397,34 @@ public class PlayoutModeSchedulerBaseTests : SchedulerTestBase |
|
|
|
new() { Duration = duration } |
|
|
|
new() { Duration = duration } |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static PlayoutModeSchedulerBase<ProgramScheduleItem> Scheduler() => |
|
|
|
|
|
|
|
new TestScheduler(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class TestScheduler : PlayoutModeSchedulerBase<ProgramScheduleItem> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
private static readonly ILoggerFactory LoggerFactory; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static TestScheduler() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Log.Logger = new LoggerConfiguration() |
|
|
|
|
|
|
|
.MinimumLevel.Debug() |
|
|
|
|
|
|
|
.WriteTo.Console() |
|
|
|
|
|
|
|
.CreateLogger(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LoggerFactory = new LoggerFactory().AddSerilog(Log.Logger); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TestScheduler() : base(LoggerFactory.CreateLogger<TestScheduler>()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override Tuple<PlayoutBuilderState, List<PlayoutItem>> Schedule( |
|
|
|
|
|
|
|
PlayoutBuilderState playoutBuilderState, |
|
|
|
|
|
|
|
Dictionary<CollectionKey, IMediaCollectionEnumerator> collectionEnumerators, |
|
|
|
|
|
|
|
ProgramScheduleItem scheduleItem, |
|
|
|
|
|
|
|
ProgramScheduleItem nextScheduleItem, |
|
|
|
|
|
|
|
DateTimeOffset hardStop) => |
|
|
|
|
|
|
|
throw new NotSupportedException(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |