using OF_DL.Models.Dtos.Common;
using OF_DL.Models.Dtos.Stories;
using OF_DL.Models.Entities.Stories;
using OF_DL.Models.Mappers;

namespace OF_DL.Tests.Models.Mappers;

public class StoriesMapperTests
{
    [Fact]
    public void FromDto_ReturnsEmptyList_WhenDtoNull()
    {
        List<Stories> result = StoriesMapper.FromDto(null);

        Assert.Empty(result);
    }

    [Fact]
    public void FromDto_MapsStories()
    {
        DateTime createdAt = new(2024, 9, 10, 11, 12, 13, DateTimeKind.Utc);

        List<StoryDto> dto =
        [
            new()
            {
                Id = 12,
                CreatedAt = createdAt,
                Media =
                [
                    new MediumDto
                    {
                        Id = 34,
                        Type = "photo",
                        CanView = true,
                        CreatedAt = createdAt,
                        Files = new FilesDto { Full = new FullDto { Url = "https://example.com/full.jpg" } }
                    }
                ]
            }
        ];

        List<Stories> result = StoriesMapper.FromDto(dto);

        Assert.Single(result);

        Stories story = result[0];
        Assert.Equal(12, story.Id);
        Assert.Equal(createdAt, story.CreatedAt);
        Assert.Single(story.Media);

        Medium media = story.Media[0];
        Assert.Equal(34, media.Id);
        Assert.NotNull(media.Files);
        Assert.NotNull(media.Files.Full);
        Assert.Equal("https://example.com/full.jpg", media.Files.Full.Url);
    }
}
