public void GivenAnInvalidCommandShouldNotCreateTransaction() { //Given var command = new CreditTransactionCommand(Guid.NewGuid(), "", 0M); //When var result = (GenericCommandResult)_transactionHandler.Handle(command); //Then Assert.False(result.Success); }
public void WhenAValidCommandIsGivenShouldBeValid() { //Given var command = new CreditTransactionCommand( Guid.NewGuid(), "description", 100M ); //When command.Validate(); //Then Assert.True(command.Valid); }
public void WhenAnInvalidcommandIsGivenShouldNotBeValid() { //Given var command = new CreditTransactionCommand( Guid.Empty, "", 0M ); //When command.Validate(); //Then Assert.True(command.Invalid); Assert.Equal(3, command.Notifications.Count); }
public void GivenAnInnexistentAccountShouldNotCreateTransaction() { //Given var command = new CreditTransactionCommand( Guid.NewGuid(), "Credito realizado", 100M); _accountRepository.GetById(command.AccountId) .ReturnsNull(); //When var result = (GenericCommandResult)_transactionHandler.Handle(command); //Then Assert.False(result.Success); Assert.Equal("Conta não localizada", result.Message); }
public void GivenAValidCommandAndAccountShouldCreateTransaction() { //Given var account = new Account("test", "1234"); _accountRepository.GetById(account.Id) .Returns(account); var command = new CreditTransactionCommand( account.Id, "Deposit", 100M); //When var result = (GenericCommandResult)_transactionHandler.Handle(command); //Then Assert.True(result.Success); }
public GenericCommandResult CreditTransaction(CreditTransactionCommand command) { return((GenericCommandResult)_transactionHandler.Handle(command)); }