public async Task ShouldReturnGenericCommandResultSucessTrueWhenGetPollByIdCommandIsValid() { PollHandler _handler = new PollHandler(new FakePollRepository(), _mockLogger.Object); var result = (GenericCommandResult)await _handler.Handle(_getPollByIdCommandValid); Assert.IsTrue(_getPollByIdCommandValid.Valid); Assert.AreEqual(true, result.Success); }
public async Task <ActionResult <GenericCommandResult> > Get(Guid id, [FromServices] PollHandler handler) { var ret = (GenericCommandResult)await handler.Handle(new UpdatePollByIdCommand(id)); if (!ret.Success) { _logger.LogWarning("Get --> {Id}", id, ret); return(BadRequest(ret)); } _logger.LogInformation("Get --> {Id}", id, ret); return(Ok(ret)); }
public async Task <ActionResult <GenericCommandResult> > Post([FromBody] CreatePollCommand command, [FromServices] PollHandler handler) { //var user = User.Claims.FirstOrDefault(x=>x.Type == "user_id")?.Value; var ret = (GenericCommandResult)await handler.Handle(command); if (!ret.Success) { _logger.LogWarning("Post --> ", ret); return(BadRequest(ret)); } _logger.LogInformation("Post --> ", ret); return(Ok(ret)); }