public async Task <List <LibraryBookDto> > Handle(RequestBookGetList request, CancellationToken cancellationToken) { var books = await context.LibraryBooks.ToListAsync(); var result = mapper.Map <List <LibraryBook>, List <LibraryBookDto> >(books); return(result); }
public async void GetBooks() { var mockContext = CreateContext(); var mapConfig = new MapperConfiguration(cfg => { cfg.AddProfile(new MappingTest()); }); var mapper = mapConfig.CreateMapper(); RequestBookGetList request = new RequestBookGetList(); HandlerBookGetList handler = new HandlerBookGetList(mockContext.Object, mapper); var list = await handler.Handle(request, new System.Threading.CancellationToken()); Assert.True(list.Any()); }