Files
ersatztv/ErsatzTV.Tests/Application/MediaCollections/SmartCollectionHandlerTests.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

51 lines
1.6 KiB
C#

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<IMediaCollectionRepository>(),
Worker,
SearchTargets,
Substitute.For<ISmartCollectionCache>());
Either<BaseError, UpdateSmartCollectionResult> result =
await handler.Handle(new UpdateSmartCollection(999, "Updated", "tag:updated"), CancellationToken.None);
LeftOf(result).ShouldBeOfType<NotFoundError>();
}
[Test]
public async Task Delete_Should_Return_NotFoundError_When_SmartCollection_Missing()
{
var handler = new DeleteSmartCollectionHandler(
Db.Factory,
SearchTargets,
Substitute.For<ISmartCollectionCache>());
Either<BaseError, Unit> result =
await handler.Handle(new DeleteSmartCollection(999), CancellationToken.None);
LeftOf(result).ShouldBeOfType<NotFoundError>();
}
private static BaseError LeftOf<TR>(Either<BaseError, TR> either) =>
either.Match(Left: e => e, Right: _ => throw new AssertionException("Expected a Left result"));
}