public async Task IfQuizNull_False() { var command = new CreateResultCommand(null); var handler = new CreateResultHandler(_mock.Object); var result = await handler.Handle(command, CancellationToken.None); Assert.IsFalse(result); }
public async Task <IActionResult> PostAnswerResult(CreateResultCommand command) { try { return(Ok(await Mediator.Send(command))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public async Task IfIdHasValue_False(string value) { var command = new CreateResultCommand(new QuizResult { _id = value }); var handler = new CreateResultHandler(_mock.Object); var result = await handler.Handle(command, CancellationToken.None); Assert.IsFalse(result); }
public async Task ResultIdNullOrEmpty_True(string value) { var command = new CreateResultCommand(new QuizResult { _id = value }); var handler = new CreateResultHandler(_mock.Object); var result = await handler.Handle(command, CancellationToken.None); Assert.IsTrue(result); }
public async Task <IActionResult> CreateResult(QuizResult quizResult) { var command = new CreateResultCommand(quizResult); var result = await _mediator.Send(command); if (result) { return(Ok()); } return(NotFound()); }