42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using AutoMapper;
|
|
using CleanArchitecture.Application.Contracts.Persistence;
|
|
using CleanArchitecture.Application.Features.Videos.Queries.GetVideosList;
|
|
using CleanArchitecture.Application.Mappings;
|
|
using CleanArchitecture.Application.UnitTests.Mocks;
|
|
using CleanArchitecture.Infrastructure.Repositories;
|
|
using Moq;
|
|
using Shouldly;
|
|
using Xunit;
|
|
|
|
namespace CleanArchitecture.Application.UnitTests.Features.Video.Queries
|
|
{
|
|
public class GetVideosListQueryHandlerXUnitTests
|
|
{
|
|
|
|
private readonly IMapper mapper;
|
|
private Mock<UnitOfWork> mockUnitOfWork;
|
|
|
|
public GetVideosListQueryHandlerXUnitTests()
|
|
{
|
|
mockUnitOfWork = MockUnitOfWork.GetUnitOfWork();
|
|
var mapperConfiguration = new MapperConfiguration(cfg =>
|
|
{
|
|
cfg.AddProfile<MappingProfile>();
|
|
});
|
|
mapper = mapperConfiguration.CreateMapper();
|
|
MockVideoRepository.AddDataVideoRepository(mockUnitOfWork.Object.StreamerDbContext);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetVideoListTest()
|
|
{
|
|
var handler = new GetVideosListQueryHandler(mockUnitOfWork.Object, mapper);
|
|
var request = new GetVideosListQuery("Alex");
|
|
var result = await handler.Handle(request, CancellationToken.None);
|
|
|
|
result.ShouldBeOfType<List<VideosVm>>();
|
|
result.Count.ShouldBe(1);
|
|
}
|
|
}
|
|
}
|