using ErsatzTV.Application.MediaCollections; using ErsatzTV.Core; using ErsatzTV.Core.Errors; using ErsatzTV.Core.Interfaces.Repositories; using ErsatzTV.Core.Search; using LanguageExt; using ErsatzTV.Tests.Support; using NSubstitute; using NUnit.Framework; using Shouldly; using Unit = LanguageExt.Unit; namespace ErsatzTV.Tests.Application.MediaCollections; [TestFixture] public class SmartCollectionHandlerTests : MediaCollectionHandlerTestBase { [Test] public async Task Update_Should_Return_NotFoundError_When_SmartCollection_Missing() { var handler = new UpdateSmartCollectionHandler( Db.Factory, Substitute.For(), Worker, SearchTargets, Substitute.For()); Either result = await handler.Handle(new UpdateSmartCollection(999, "Updated", "tag:updated"), CancellationToken.None); LeftOf(result).ShouldBeOfType(); } [Test] public async Task Delete_Should_Return_NotFoundError_When_SmartCollection_Missing() { var handler = new DeleteSmartCollectionHandler( Db.Factory, SearchTargets, Substitute.For()); Either result = await handler.Handle(new DeleteSmartCollection(999), CancellationToken.None); LeftOf(result).ShouldBeOfType(); } private static BaseError LeftOf(Either either) => either.Match(Left: e => e, Right: _ => throw new AssertionException("Expected a Left result")); }