public async Task ThrowAsyncIfNotExists() { var mockRepository = new Mock <IRepository <ToDoList> >(); mockRepository.Setup(x => x.Get(It.IsAny <Guid>())).ReturnsAsync(null as ToDoList); mockRepository.Setup(x => x.Update(It.IsAny <ToDoList>())).ReturnsAsync(null as ToDoList); var handler = new UpdateToDoListDescriptionCommandHandler(mockRepository.Object, new Mock <ILogger <UpdateToDoListDescriptionCommandHandler> >().Object); await Assert.ThrowsAsync <NotFoundException>(async() => await handler.Handle(new UpdateToDoListDescriptionCommand(), new System.Threading.CancellationToken())); }
public async Task ReturnViewModelIfValid() { var expectedToDoList = Builder <ToDoList> .CreateNew().Build(); var mockRepository = new Mock <IRepository <ToDoList> >(); mockRepository.Setup(x => x.Get(It.IsAny <Guid>())).ReturnsAsync(expectedToDoList); mockRepository.Setup(x => x.Update(It.IsAny <ToDoList>())).ReturnsAsync(expectedToDoList); var handler = new UpdateToDoListDescriptionCommandHandler(mockRepository.Object, new Mock <ILogger <UpdateToDoListDescriptionCommandHandler> >().Object); var response = await handler.Handle(new UpdateToDoListDescriptionCommand(), new System.Threading.CancellationToken()); Assert.Equal(response.Id, expectedToDoList.Id); }