public async void Handle_WithValidUser_CreatesUserSessionSuccess() { //Arrange var command = new Faker <CreateUserSessionCommand>() .RuleFor(p => p.Email, "*****@*****.**") .RuleFor(p => p.Password, "123") .Generate(); //Act var result = await _handler.Handle(command, new CancellationToken()); //Assert result.Success .Should() .BeTrue(); }
public CommandResponse Add(Account account) { var createAccountCommand = new CreateAccountCommand { AccountId = Guid.Parse(account.Id), HolderName = account.HolderName }; return(_cmdHandler.Handle(createAccountCommand)); }
public IActionResult DeleteAccount(int accountId) { if (accountId == null) { return(BadRequest()); } try { var command = new DeleteAccountCommand(accountId); var commandHandler = new AccountCommandHandler(_accountRepository); commandHandler.Handle(command); return(Ok()); } catch (CommandValidationException <eAccountError> ex) { return(BadRequest(ex.Error.ToString())); } }
public IActionResult PutAccount([FromBody] AccountPutRequest accountPutRequest, [FromRoute] int accountId) { if (accountPutRequest == null || accountId == null) { return(BadRequest()); } try { var command = accountPutRequest.MapToCommand(accountId); var commandHandler = new AccountCommandHandler(_accountRepository); var account = commandHandler.Handle(command); var response = account.MapToResponse(); return(Ok(response)); } catch (CommandValidationException <eAccountError> ex) { return(BadRequest(ex.Error.ToString())); } }