Exemplo n.º 1
0
        public async Task DeleteCommand_ThrowsNotFoundException_WhenLeaveNotFound()
        {
            Leave nullLeave = null;
            var   command   = new DeleteLeaveCommand {
                LeaveId = 1
            };
            var handler = new DeleteLeaveCommandHandler(mockRepo.Object);

            mockRepo.Setup(x => x.GetById(It.IsAny <int>())).ReturnsAsync(nullLeave);

            await Assert.ThrowsAsync <NotFoundException>(() => handler.Handle(command, CancellationToken.None));
        }
Exemplo n.º 2
0
        public async Task DeleteCommand_DeletesCorrectLeave()
        {
            var command = new DeleteLeaveCommand {
                LeaveId = 1
            };
            var handler = new DeleteLeaveCommandHandler(mockRepo.Object);

            mockRepo.Setup(x => x.GetById(command.LeaveId)).ReturnsAsync(new Leave());

            await handler.Handle(command, CancellationToken.None);

            mockRepo.Verify(x => x.GetById(command.LeaveId), Times.Once());
            mockRepo.Verify(x => x.Remove(It.IsAny <Leave>()), Times.Once());
        }