Refactor GridScheduleGenerator and related components to improve cursor management and group handling
Updated the GridScheduleGenerator to reset cursors for slots with no aired positions, ensuring proper state management during rebuilds. Introduced a new method, ResetUnairedCursorsAsync, to handle cursor resets effectively. Enhanced the handling of interstitial groups in the scheduling process, preventing them from being included in slots or fallback groups. Updated related tests to verify the correct behavior of these changes, ensuring robust scheduling logic and accurate group categorization.
This commit is contained in:
@@ -559,6 +559,37 @@ public class SchedulePlannerTests
|
||||
Assert.Contains(result.Items, i => i.SlotId == background.SlotId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Pad_CapCountsWholeSeam_WhenBackgroundHasNothingToPlay()
|
||||
{
|
||||
// Часовая дыра и пустой фоновый слой: добор до якоря и остаток перед ним сходятся встык,
|
||||
// и без общего потолка в эфир ушло бы двадцать минут рекламы подряд вместо десяти.
|
||||
var result = Run(
|
||||
Input(
|
||||
[Slot(T0.AddHours(1), 30, [Element(1, 30)], isAnchor: true)],
|
||||
horizonHours: 2,
|
||||
pad: [Ad(5)],
|
||||
maxPad: TimeSpan.FromMinutes(10)
|
||||
)
|
||||
);
|
||||
|
||||
// Считается самый длинный рекламный блок подряд: два добора по разные стороны от фона —
|
||||
// это два шва, а сошедшиеся встык — один, и он потолком и ограничен.
|
||||
var longest = TimeSpan.Zero;
|
||||
var current = TimeSpan.Zero;
|
||||
foreach (var item in result.Items.OrderBy(i => i.StartsAtUtc))
|
||||
{
|
||||
current =
|
||||
item.Kind == PlannedItemKind.Ad
|
||||
? current + (item.EndsAtUtc - item.StartsAtUtc)
|
||||
: TimeSpan.Zero;
|
||||
if (current > longest)
|
||||
longest = current;
|
||||
}
|
||||
|
||||
Assert.Equal(TimeSpan.FromMinutes(10), longest);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Pad_ClosesTailWhenProgrammeDoesNotFit()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user