Files
ersatztv/ErsatzTV.Tests/Support/MediaCollectionHandlerTestBase.cs
T
timothy fb3f2856da
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 4m5s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 5m9s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
feat(api): add collections REST endpoints
Refs #35
2026-06-27 21:43:11 +02:00

52 lines
1.5 KiB
C#

using System.Threading.Channels;
using ErsatzTV.Application;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Search;
using ErsatzTV.Infrastructure.Data;
using NSubstitute;
using NUnit.Framework;
namespace ErsatzTV.Tests.Support;
public abstract class MediaCollectionHandlerTestBase
{
protected InMemoryTvContext Db = null!;
protected ChannelWriter<IBackgroundServiceRequest> Worker = null!;
protected ISearchTargets SearchTargets = null!;
[SetUp]
public async Task BaseSetUp()
{
Db = await InMemoryTvContext.CreateAsync();
Worker = System.Threading.Channels.Channel.CreateUnbounded<IBackgroundServiceRequest>().Writer;
SearchTargets = Substitute.For<ISearchTargets>();
}
[TearDown]
public async Task BaseTearDown() => await Db.DisposeAsync();
protected async Task SeedCollection(int id, string name = "Collection")
{
await using TvContext context = Db.CreateContext();
context.Collections.Add(new Collection
{
Id = id,
Name = name,
MediaItems = []
});
await context.SaveChangesAsync();
}
protected async Task SeedSmartCollection(int id, string name = "Smart", string query = "tag:family")
{
await using TvContext context = Db.CreateContext();
context.SmartCollections.Add(new SmartCollection
{
Id = id,
Name = name,
Query = query
});
await context.SaveChangesAsync();
}
}