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 Worker = null!; protected ISearchTargets SearchTargets = null!; [SetUp] public async Task BaseSetUp() { Db = await InMemoryTvContext.CreateAsync(); Worker = System.Threading.Channels.Channel.CreateUnbounded().Writer; SearchTargets = Substitute.For(); } [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(); } }