public async Task ResultTrue() { var command = new DeleteQuizCommand("1"); var handler = new DeleteQuizHandler(_mock.Object); var result = await handler.Handle(command, CancellationToken.None); Assert.AreEqual(result, true); }
public async Task ResultFalse(string id) { var command = new DeleteQuizCommand(id); var handler = new DeleteQuizHandler(_mock.Object); var result = await handler.Handle(command, CancellationToken.None); Assert.AreEqual(result, false); }
public async Task ResultNotNull() { var command = new DeleteQuizCommand(""); var handler = new DeleteQuizHandler(_mock.Object); var result = await handler.Handle(command, CancellationToken.None); Assert.NotNull(result); }
public async Task <IActionResult> DeleteQuiz(int quizId) { var command = new DeleteQuizCommand() { QuizId = quizId }; await Mediator.Send(command); return(NoContent()); }
public async Task <IActionResult> DeleteQuiz(string id) { var command = new DeleteQuizCommand(id); var result = await _mediator.Send(command); if (result) { return(Ok()); } return(NotFound()); }
public async Task Handle_ValidQuizData_ChapterShouldNotFound() { //Arrange var quizId = Guid.NewGuid(); var command = new DeleteQuizCommand(quizId); _quizRepositoryMock.Setup(x => x.AnyAsync(It.IsAny <ISpecification <Quiz> >())) .ReturnsAsync(false); //Act //Assert await Assert.ThrowsAsync <InvalidOperationException>(() => _quizCommandHandler.Handle(command, CancellationToken.None)); _autoMocker.VerifyAll(); }
public async Task Handle_ValidQuizData_ShouldSuccess() { //Arrange var quizId = Guid.NewGuid(); var command = new DeleteQuizCommand(quizId); _quizRepositoryMock.Setup(x => x.AnyAsync(It.IsAny <ISpecification <Quiz> >())) .ReturnsAsync(true); _quizRepositoryMock.Setup(x => x.DeleteAsync(It.IsAny <ISpecification <Quiz> >())) .ReturnsAsync(true); _sendEndpointProviderMock = _autoMocker.GetMock <ISendEndpointProvider>(); _sendEndpointProviderMock.Setup(x => x.GetSendEndpoint(It.IsAny <Uri>())) .Returns(Task.FromResult(_sendEndpointMock.Object)); var result = await _quizCommandHandler.Handle(command, CancellationToken.None); //Assert Assert.True(result); _autoMocker.VerifyAll(); }