|
|
|
@ -30,10 +30,12 @@ namespace ErsatzTV.Core.Tests.Scheduling; |
|
|
|
[Explicit] |
|
|
|
[Explicit] |
|
|
|
public class ScheduleIntegrationTests |
|
|
|
public class ScheduleIntegrationTests |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
[SetUp] |
|
|
|
|
|
|
|
public void SetUp() => _cancellationToken = new CancellationTokenSource(TimeSpan.FromMinutes(1)).Token; |
|
|
|
|
|
|
|
|
|
|
|
private CancellationToken _cancellationToken; |
|
|
|
private CancellationToken _cancellationToken; |
|
|
|
|
|
|
|
|
|
|
|
public ScheduleIntegrationTests() |
|
|
|
public ScheduleIntegrationTests() => |
|
|
|
{ |
|
|
|
|
|
|
|
Log.Logger = new LoggerConfiguration() |
|
|
|
Log.Logger = new LoggerConfiguration() |
|
|
|
.MinimumLevel.Debug() |
|
|
|
.MinimumLevel.Debug() |
|
|
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) |
|
|
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) |
|
|
|
@ -41,13 +43,6 @@ public class ScheduleIntegrationTests |
|
|
|
.WriteTo.Console() |
|
|
|
.WriteTo.Console() |
|
|
|
.Destructure.UsingAttributes() |
|
|
|
.Destructure.UsingAttributes() |
|
|
|
.CreateLogger(); |
|
|
|
.CreateLogger(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[SetUp] |
|
|
|
|
|
|
|
public void SetUp() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_cancellationToken = new CancellationTokenSource(TimeSpan.FromMinutes(1)).Token; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
[Test] |
|
|
|
public async Task TestExistingData() |
|
|
|
public async Task TestExistingData() |
|
|
|
@ -82,13 +77,13 @@ public class ScheduleIntegrationTests |
|
|
|
o.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); |
|
|
|
o.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); |
|
|
|
o.MigrationsAssembly("ErsatzTV.Infrastructure"); |
|
|
|
o.MigrationsAssembly("ErsatzTV.Infrastructure"); |
|
|
|
})); |
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
SqlMapper.AddTypeHandler(new DateTimeOffsetHandler()); |
|
|
|
SqlMapper.AddTypeHandler(new DateTimeOffsetHandler()); |
|
|
|
SqlMapper.AddTypeHandler(new GuidHandler()); |
|
|
|
SqlMapper.AddTypeHandler(new GuidHandler()); |
|
|
|
SqlMapper.AddTypeHandler(new TimeSpanHandler()); |
|
|
|
SqlMapper.AddTypeHandler(new TimeSpanHandler()); |
|
|
|
|
|
|
|
|
|
|
|
services.AddSingleton((Func<IServiceProvider, ILoggerFactory>)(_ => new SerilogLoggerFactory())); |
|
|
|
services.AddSingleton((Func<IServiceProvider, ILoggerFactory>)(_ => new SerilogLoggerFactory())); |
|
|
|
|
|
|
|
|
|
|
|
services.AddScoped<ISearchRepository, SearchRepository>(); |
|
|
|
services.AddScoped<ISearchRepository, SearchRepository>(); |
|
|
|
services.AddScoped<ICachingSearchRepository, CachingSearchRepository>(); |
|
|
|
services.AddScoped<ICachingSearchRepository, CachingSearchRepository>(); |
|
|
|
services.AddScoped<IConfigElementRepository, ConfigElementRepository>(); |
|
|
|
services.AddScoped<IConfigElementRepository, ConfigElementRepository>(); |
|
|
|
@ -119,7 +114,7 @@ public class ScheduleIntegrationTests |
|
|
|
await searchIndex.Rebuild( |
|
|
|
await searchIndex.Rebuild( |
|
|
|
provider.GetRequiredService<ICachingSearchRepository>(), |
|
|
|
provider.GetRequiredService<ICachingSearchRepository>(), |
|
|
|
provider.GetRequiredService<IFallbackMetadataProvider>()); |
|
|
|
provider.GetRequiredService<IFallbackMetadataProvider>()); |
|
|
|
|
|
|
|
|
|
|
|
var builder = new PlayoutBuilder( |
|
|
|
var builder = new PlayoutBuilder( |
|
|
|
new ConfigElementRepository(factory), |
|
|
|
new ConfigElementRepository(factory), |
|
|
|
new MediaCollectionRepository(new Mock<IClient>().Object, searchIndex, factory), |
|
|
|
new MediaCollectionRepository(new Mock<IClient>().Object, searchIndex, factory), |
|
|
|
@ -140,10 +135,10 @@ public class ScheduleIntegrationTests |
|
|
|
await context.SaveChangesAsync(_cancellationToken); |
|
|
|
await context.SaveChangesAsync(_cancellationToken); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (var i = 1; i <= (24 * 1); i++) |
|
|
|
for (var i = 1; i <= 24 * 1; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
await using TvContext context = await factory.CreateDbContextAsync(_cancellationToken); |
|
|
|
await using TvContext context = await factory.CreateDbContextAsync(_cancellationToken); |
|
|
|
|
|
|
|
|
|
|
|
Option<Playout> maybePlayout = await GetPlayout(context, PLAYOUT_ID); |
|
|
|
Option<Playout> maybePlayout = await GetPlayout(context, PLAYOUT_ID); |
|
|
|
Playout playout = maybePlayout.ValueUnsafe(); |
|
|
|
Playout playout = maybePlayout.ValueUnsafe(); |
|
|
|
|
|
|
|
|
|
|
|
@ -156,11 +151,11 @@ public class ScheduleIntegrationTests |
|
|
|
|
|
|
|
|
|
|
|
await context.SaveChangesAsync(_cancellationToken); |
|
|
|
await context.SaveChangesAsync(_cancellationToken); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (var i = 25; i <= 26; i++) |
|
|
|
for (var i = 25; i <= 26; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
await using TvContext context = await factory.CreateDbContextAsync(_cancellationToken); |
|
|
|
await using TvContext context = await factory.CreateDbContextAsync(_cancellationToken); |
|
|
|
|
|
|
|
|
|
|
|
Option<Playout> maybePlayout = await GetPlayout(context, PLAYOUT_ID); |
|
|
|
Option<Playout> maybePlayout = await GetPlayout(context, PLAYOUT_ID); |
|
|
|
Playout playout = maybePlayout.ValueUnsafe(); |
|
|
|
Playout playout = maybePlayout.ValueUnsafe(); |
|
|
|
|
|
|
|
|
|
|
|
@ -204,7 +199,7 @@ public class ScheduleIntegrationTests |
|
|
|
o.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); |
|
|
|
o.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); |
|
|
|
o.MigrationsAssembly("ErsatzTV.Infrastructure"); |
|
|
|
o.MigrationsAssembly("ErsatzTV.Infrastructure"); |
|
|
|
})); |
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
SqlMapper.AddTypeHandler(new DateTimeOffsetHandler()); |
|
|
|
SqlMapper.AddTypeHandler(new DateTimeOffsetHandler()); |
|
|
|
SqlMapper.AddTypeHandler(new GuidHandler()); |
|
|
|
SqlMapper.AddTypeHandler(new GuidHandler()); |
|
|
|
SqlMapper.AddTypeHandler(new TimeSpanHandler()); |
|
|
|
SqlMapper.AddTypeHandler(new TimeSpanHandler()); |
|
|
|
@ -226,7 +221,7 @@ public class ScheduleIntegrationTests |
|
|
|
{ |
|
|
|
{ |
|
|
|
Path = "Test LibraryPath" |
|
|
|
Path = "Test LibraryPath" |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var library = new LocalLibrary |
|
|
|
var library = new LocalLibrary |
|
|
|
{ |
|
|
|
{ |
|
|
|
MediaKind = LibraryMediaKind.Movies, |
|
|
|
MediaKind = LibraryMediaKind.Movies, |
|
|
|
@ -236,7 +231,7 @@ public class ScheduleIntegrationTests |
|
|
|
|
|
|
|
|
|
|
|
await dbContext.Libraries.AddAsync(library, _cancellationToken); |
|
|
|
await dbContext.Libraries.AddAsync(library, _cancellationToken); |
|
|
|
await dbContext.SaveChangesAsync(_cancellationToken); |
|
|
|
await dbContext.SaveChangesAsync(_cancellationToken); |
|
|
|
|
|
|
|
|
|
|
|
var movies = new List<Movie>(); |
|
|
|
var movies = new List<Movie>(); |
|
|
|
for (var i = 1; i < 25; i++) |
|
|
|
for (var i = 1; i < 25; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -287,9 +282,9 @@ public class ScheduleIntegrationTests |
|
|
|
|
|
|
|
|
|
|
|
int playoutId = await AddTestData(dbContext, scheduleItems); |
|
|
|
int playoutId = await AddTestData(dbContext, scheduleItems); |
|
|
|
|
|
|
|
|
|
|
|
DateTimeOffset start = new DateTimeOffset(2022, 7, 26, 8, 0, 5, TimeSpan.FromHours(-5)); |
|
|
|
var start = new DateTimeOffset(2022, 7, 26, 8, 0, 5, TimeSpan.FromHours(-5)); |
|
|
|
DateTimeOffset finish = start.AddDays(2); |
|
|
|
DateTimeOffset finish = start.AddDays(2); |
|
|
|
|
|
|
|
|
|
|
|
var builder = new PlayoutBuilder( |
|
|
|
var builder = new PlayoutBuilder( |
|
|
|
new ConfigElementRepository(factory), |
|
|
|
new ConfigElementRepository(factory), |
|
|
|
new MediaCollectionRepository(new Mock<IClient>().Object, new Mock<ISearchIndex>().Object, factory), |
|
|
|
new MediaCollectionRepository(new Mock<IClient>().Object, new Mock<ISearchIndex>().Object, factory), |
|
|
|
@ -299,10 +294,10 @@ public class ScheduleIntegrationTests |
|
|
|
new Mock<ILocalFileSystem>().Object, |
|
|
|
new Mock<ILocalFileSystem>().Object, |
|
|
|
provider.GetRequiredService<ILogger<PlayoutBuilder>>()); |
|
|
|
provider.GetRequiredService<ILogger<PlayoutBuilder>>()); |
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i <= (24 * 4); i++) |
|
|
|
for (var i = 0; i <= 24 * 4; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
await using TvContext context = await factory.CreateDbContextAsync(_cancellationToken); |
|
|
|
await using TvContext context = await factory.CreateDbContextAsync(_cancellationToken); |
|
|
|
|
|
|
|
|
|
|
|
Option<Playout> maybePlayout = await GetPlayout(context, playoutId); |
|
|
|
Option<Playout> maybePlayout = await GetPlayout(context, playoutId); |
|
|
|
Playout playout = maybePlayout.ValueUnsafe(); |
|
|
|
Playout playout = maybePlayout.ValueUnsafe(); |
|
|
|
|
|
|
|
|
|
|
|
@ -326,7 +321,7 @@ public class ScheduleIntegrationTests |
|
|
|
|
|
|
|
|
|
|
|
await dbContext.FFmpegProfiles.AddAsync(ffmpegProfile); |
|
|
|
await dbContext.FFmpegProfiles.AddAsync(ffmpegProfile); |
|
|
|
await dbContext.SaveChangesAsync(); |
|
|
|
await dbContext.SaveChangesAsync(); |
|
|
|
|
|
|
|
|
|
|
|
var channel = new Channel(Guid.Parse("00000000-0000-0000-0000-000000000001")) |
|
|
|
var channel = new Channel(Guid.Parse("00000000-0000-0000-0000-000000000001")) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Name = "Test Channel", |
|
|
|
Name = "Test Channel", |
|
|
|
@ -360,12 +355,10 @@ public class ScheduleIntegrationTests |
|
|
|
return playout.Id; |
|
|
|
return playout.Id; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static async Task<Option<Playout>> GetPlayout(TvContext dbContext, int playoutId) |
|
|
|
private static async Task<Option<Playout>> GetPlayout(TvContext dbContext, int playoutId) => |
|
|
|
{ |
|
|
|
await dbContext.Playouts |
|
|
|
return await dbContext.Playouts |
|
|
|
|
|
|
|
.Include(p => p.Channel) |
|
|
|
.Include(p => p.Channel) |
|
|
|
.Include(p => p.Items) |
|
|
|
.Include(p => p.Items) |
|
|
|
|
|
|
|
|
|
|
|
.Include(p => p.ProgramScheduleAlternates) |
|
|
|
.Include(p => p.ProgramScheduleAlternates) |
|
|
|
.ThenInclude(a => a.ProgramSchedule) |
|
|
|
.ThenInclude(a => a.ProgramSchedule) |
|
|
|
.ThenInclude(ps => ps.Items) |
|
|
|
.ThenInclude(ps => ps.Items) |
|
|
|
@ -394,12 +387,10 @@ public class ScheduleIntegrationTests |
|
|
|
.ThenInclude(a => a.ProgramSchedule) |
|
|
|
.ThenInclude(a => a.ProgramSchedule) |
|
|
|
.ThenInclude(ps => ps.Items) |
|
|
|
.ThenInclude(ps => ps.Items) |
|
|
|
.ThenInclude(psi => psi.FallbackFiller) |
|
|
|
.ThenInclude(psi => psi.FallbackFiller) |
|
|
|
|
|
|
|
|
|
|
|
.Include(p => p.ProgramScheduleAnchors) |
|
|
|
.Include(p => p.ProgramScheduleAnchors) |
|
|
|
.ThenInclude(a => a.EnumeratorState) |
|
|
|
.ThenInclude(a => a.EnumeratorState) |
|
|
|
.Include(p => p.ProgramScheduleAnchors) |
|
|
|
.Include(p => p.ProgramScheduleAnchors) |
|
|
|
.ThenInclude(a => a.MediaItem) |
|
|
|
.ThenInclude(a => a.MediaItem) |
|
|
|
|
|
|
|
|
|
|
|
.Include(p => p.ProgramSchedule) |
|
|
|
.Include(p => p.ProgramSchedule) |
|
|
|
.ThenInclude(ps => ps.Items) |
|
|
|
.ThenInclude(ps => ps.Items) |
|
|
|
.ThenInclude(psi => psi.Collection) |
|
|
|
.ThenInclude(psi => psi.Collection) |
|
|
|
@ -422,5 +413,4 @@ public class ScheduleIntegrationTests |
|
|
|
.ThenInclude(ps => ps.Items) |
|
|
|
.ThenInclude(ps => ps.Items) |
|
|
|
.ThenInclude(psi => psi.FallbackFiller) |
|
|
|
.ThenInclude(psi => psi.FallbackFiller) |
|
|
|
.SelectOneAsync(p => p.Id, p => p.Id == playoutId); |
|
|
|
.SelectOneAsync(p => p.Id, p => p.Id == playoutId); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|