Browse Source

fix effective block tests running on github

pull/2600/head
Jason Dove 9 months ago
parent
commit
6e1b51f45b
No known key found for this signature in database
  1. 24
      ErsatzTV.Core.Tests/Scheduling/BlockScheduling/EffectiveBlockTests.cs
  2. 2
      ErsatzTV.Core/Scheduling/BlockScheduling/BlockPlayoutBuilder.cs
  3. 3
      ErsatzTV.Core/Scheduling/BlockScheduling/EffectiveBlock.cs

24
ErsatzTV.Core.Tests/Scheduling/BlockScheduling/EffectiveBlockTests.cs

@ -7,8 +7,8 @@ namespace ErsatzTV.Core.Tests.Scheduling.BlockScheduling; @@ -7,8 +7,8 @@ namespace ErsatzTV.Core.Tests.Scheduling.BlockScheduling;
public static class EffectiveBlockTests
{
private static DateTimeOffset GetLocalDate(int year, int month, int day) =>
new(year, month, day, 0, 0, 0, TimeSpan.FromHours(-6));
private static DateTimeOffset GetLocalDate(int year, int month, int day, TimeZoneInfo tz) =>
new(year, month, day, 0, 0, 0, tz.GetUtcOffset(new DateTime(year, month, day)));
private static Template SingleBlockTemplate(DateTimeOffset dateUpdated)
{
@ -60,9 +60,10 @@ public static class EffectiveBlockTests @@ -60,9 +60,10 @@ public static class EffectiveBlockTests
}
];
DateTimeOffset start = GetLocalDate(2024, 1, 15).AddHours(9);
TimeZoneInfo tz = TimeZoneInfo.Local;
DateTimeOffset start = GetLocalDate(2024, 1, 15, tz).AddHours(9);
List<EffectiveBlock> result = EffectiveBlock.GetEffectiveBlocks(templates, start, 5);
List<EffectiveBlock> result = EffectiveBlock.GetEffectiveBlocks(templates, start, tz, 5);
result.Count.ShouldBe(0);
}
@ -85,20 +86,21 @@ public static class EffectiveBlockTests @@ -85,20 +86,21 @@ public static class EffectiveBlockTests
}
];
DateTimeOffset start = GetLocalDate(2024, 1, 15).AddHours(9);
TimeZoneInfo tz = TimeZoneInfo.Local;
DateTimeOffset start = GetLocalDate(2024, 1, 15, tz).AddHours(9);
List<EffectiveBlock> result = EffectiveBlock.GetEffectiveBlocks(templates, start, 5);
List<EffectiveBlock> result = EffectiveBlock.GetEffectiveBlocks(templates, start, tz, 5);
result.Count.ShouldBe(3);
result[0].Start.DayOfWeek.ShouldBe(DayOfWeek.Monday);
result[0].Start.Date.ShouldBe(GetLocalDate(2024, 1, 15).Date);
result[0].Start.Date.ShouldBe(GetLocalDate(2024, 1, 15, tz).Date);
result[1].Start.DayOfWeek.ShouldBe(DayOfWeek.Wednesday);
result[1].Start.Date.ShouldBe(GetLocalDate(2024, 1, 17).Date);
result[1].Start.Date.ShouldBe(GetLocalDate(2024, 1, 17, tz).Date);
result[2].Start.DayOfWeek.ShouldBe(DayOfWeek.Friday);
result[2].Start.Date.ShouldBe(GetLocalDate(2024, 1, 19).Date);
result[2].Start.Date.ShouldBe(GetLocalDate(2024, 1, 19, tz).Date);
}
[Test]
@ -125,7 +127,7 @@ public static class EffectiveBlockTests @@ -125,7 +127,7 @@ public static class EffectiveBlockTests
var start = new DateTime(2024, 3, 9, 0, 0, 0, DateTimeKind.Unspecified);
var dto = new DateTimeOffset(start, tz.GetUtcOffset(start));
List<EffectiveBlock> result = EffectiveBlock.GetEffectiveBlocks(templates, dto, 5);
List<EffectiveBlock> result = EffectiveBlock.GetEffectiveBlocks(templates, dto, tz, 5);
result.Count.ShouldBe(5);
@ -164,7 +166,7 @@ public static class EffectiveBlockTests @@ -164,7 +166,7 @@ public static class EffectiveBlockTests
var start = new DateTime(2024, 11, 2, 0, 0, 0, DateTimeKind.Unspecified);
var dto = new DateTimeOffset(start, tz.GetUtcOffset(start));
List<EffectiveBlock> result = EffectiveBlock.GetEffectiveBlocks(templates, dto, 5);
List<EffectiveBlock> result = EffectiveBlock.GetEffectiveBlocks(templates, dto, tz, 5);
result.Count.ShouldBe(5);

2
ErsatzTV.Core/Scheduling/BlockScheduling/BlockPlayoutBuilder.cs

@ -55,7 +55,7 @@ public class BlockPlayoutBuilder( @@ -55,7 +55,7 @@ public class BlockPlayoutBuilder(
// get blocks to schedule
List<EffectiveBlock> blocksToSchedule =
EffectiveBlock.GetEffectiveBlocks(referenceData.PlayoutTemplates, start, daysToBuild);
EffectiveBlock.GetEffectiveBlocks(referenceData.PlayoutTemplates, start, TimeZoneInfo.Local, daysToBuild);
if (blocksToSchedule.Count == 0)
{

3
ErsatzTV.Core/Scheduling/BlockScheduling/EffectiveBlock.cs

@ -7,10 +7,9 @@ internal record EffectiveBlock(Block Block, BlockKey BlockKey, DateTimeOffset St @@ -7,10 +7,9 @@ internal record EffectiveBlock(Block Block, BlockKey BlockKey, DateTimeOffset St
public static List<EffectiveBlock> GetEffectiveBlocks(
ICollection<PlayoutTemplate> templates,
DateTimeOffset start,
TimeZoneInfo timeZone,
int daysToBuild)
{
var timeZone = TimeZoneInfo.Local;
DateTimeOffset finish = start.AddDays(daysToBuild);
var effectiveBlocks = new List<EffectiveBlock>();

Loading…
Cancel
Save