コード例 #1
0
        public void ShouldReturnSuccessWhenSendAInvalidCommand()
        {
            var handler = new CreateUserHandler(new FakeUserRepository());
            var result  = (CommandResult)handler.handle(FakeCommandCreateUser.invalidCommand());

            Assert.AreEqual(false, result.Success);
        }
コード例 #2
0
        public async Task <ActionResult> Post([FromBody] CommandCreateUser command,
                                              [FromServices] CreateUserHandler handler)
        {
            var result = (CommandResult)handler.handle(command);

            if (!result.Success)
            {
                return(BadRequest(result));
            }

            return(Ok(result));
        }