Beispiel #1
0
        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 RenameToDoListCommandHandler(mockRepository.Object, new Mock <ILogger <RenameToDoListCommandHandler> >().Object);

            await Assert.ThrowsAsync <NotFoundException>(async() => await handler.Handle(new RenameToDoListCommand(), new System.Threading.CancellationToken()));
        }
Beispiel #2
0
        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 RenameToDoListCommandHandler(mockRepository.Object, new Mock <ILogger <RenameToDoListCommandHandler> >().Object);

            var response = await handler.Handle(new RenameToDoListCommand(), new System.Threading.CancellationToken());

            Assert.Equal(response.Id, expectedToDoList.Id);
        }