using TeleWave.Domain.Library;
using Xunit;

namespace TeleWave.Domain.Tests.Library;

public class ShowEpisodeTests
{
    private static ShowEpisode NewEpisode() =>
        Show.Create("A", ShowKind.Series).AddEpisode(Guid.NewGuid());

    [Fact]
    public void SetNumbers_StoresSeasonEpisode()
    {
        var e = NewEpisode();
        e.SetNumbers(3, 7);

        Assert.Equal(3, e.Season);
        Assert.Equal(7, e.Episode);
    }

    [Fact]
    public void ApplyMetadata_SetsFields_StillOnlyWhenProvided()
    {
        var e = NewEpisode();
        var still = Guid.NewGuid();
        var air = new DateOnly(2020, 5, 1);

        e.ApplyMetadata("Title", "Overview", still, air);
        Assert.Equal("Title", e.Title);
        Assert.Equal("Overview", e.Overview);
        Assert.Equal(still, e.StillImageId);
        Assert.Equal(air, e.AirDate);

        // Повторно без кадра — существующий не затирается.
        e.ApplyMetadata("T2", "O2", null, null);
        Assert.Equal(still, e.StillImageId);
        Assert.Equal("T2", e.Title);
    }

    [Fact]
    public void ClearMetadata_ResetsAll()
    {
        var e = NewEpisode();
        e.ApplyMetadata("T", "O", Guid.NewGuid(), new DateOnly(2020, 1, 1));

        e.ClearMetadata();

        Assert.Null(e.Title);
        Assert.Null(e.Overview);
        Assert.Null(e.StillImageId);
        Assert.Null(e.AirDate);
    }
}
