using PLib.Application.Abstractions;
using PLib.Domain.Videos;
namespace PLib.Tests.Library;
/// Hand-written double mirroring the EF repository's lookup-by-normalized-name rule.
internal sealed class InMemoryLabelRepository : ILabelRepository
{
private readonly List _labels = [];
public Task> GetAllAsync(CancellationToken cancellationToken = default) =>
Task.FromResult>([.. _labels]);
public Task FindAsync(
LabelKind kind,
string name,
CancellationToken cancellationToken = default)
{
var normalized = LibraryLabel.Normalize(name);
return Task.FromResult(_labels.FirstOrDefault(
label => label.Kind == kind && label.NormalizedName == normalized));
}
public Task AddAsync(LibraryLabel label, CancellationToken cancellationToken = default)
{
_labels.Add(label);
return Task.CompletedTask;
}
public Task RemoveAsync(LibraryLabel label, CancellationToken cancellationToken = default)
{
_labels.Remove(label);
return Task.CompletedTask;
}
}