using OF_DL.Models.Dtos.Lists;
using OF_DL.Models.Entities.Lists;
using OF_DL.Models.Mappers;

namespace OF_DL.Tests.Models.Mappers;

public class UserListsMapperTests
{
    [Fact]
    public void FromDto_ReturnsDefaults_WhenDtoNull()
    {
        UserList result = UserListsMapper.FromDto(null as UserListDto);

        Assert.False(result.HasMore);
        Assert.Empty(result.List);
    }

    [Fact]
    public void FromDto_MapsUserListItems()
    {
        UserListDto dto = new() { HasMore = true, List = [new UserListItemDto { Id = "1", Name = "Favorites" }] };

        UserList result = UserListsMapper.FromDto(dto);

        Assert.True(result.HasMore);
        Assert.Single(result.List);
        Assert.Equal("1", result.List[0].Id);
        Assert.Equal("Favorites", result.List[0].Name);
    }

    [Fact]
    public void FromDto_UsersList_ReturnsEmptyList_WhenDtoNull()
    {
        List<UsersList> result = UserListsMapper.FromDto((List<UsersListDto>?)null);

        Assert.Empty(result);
    }

    [Fact]
    public void FromDto_UsersList_MapsItems()
    {
        List<UsersListDto> dto = [new() { Username = "creator" }];

        List<UsersList> result = UserListsMapper.FromDto(dto);

        Assert.Single(result);
        Assert.Equal("creator", result[0].Username);
    }
}
