public async Task CanWithdrawCashWithOverdraftLimitFromValidAccount() { decimal depositeAmount = 5000; decimal overdraftLimit = 2000; decimal withdrawAmount = 7000; var accountCreated = new AccountCreated(CorrelatedMessage.NewRoot()) { AccountId = _accountId, AccountHolderName = "Tushar" }; var cmdDepositCash = new DepositCash { AccountId = _accountId, DepositAmount = depositeAmount }; var evtCashDeposited = new CashDeposited(cmdDepositCash) { AccountId = _accountId, DepositAmount = depositeAmount }; var cmdConfigureOverdraftLimit = new ConfigureOverdraftLimit { AccountId = _accountId, OverdraftLimit = overdraftLimit }; var evOverdraftLimitConfigured = new OverdraftLimitConfigured(cmdConfigureOverdraftLimit) { AccountId = cmdConfigureOverdraftLimit.AccountId, OverdraftLimit = cmdConfigureOverdraftLimit.OverdraftLimit }; var cmd = new WithdrawCash() { AccountId = _accountId, WithdrawAmount = withdrawAmount }; var ev = new CashWithdrawn(cmd) { AccountId = _accountId, WithdrawAmount = withdrawAmount }; await _runner.Run( def => def.Given(accountCreated, evtCashDeposited, evOverdraftLimitConfigured).When(cmd).Then(ev) ); }
public async Task ConfigureOverdraftLimitShouldThrowExceptionWhenAccountIsNotPresent() { decimal overdraftLimit = 500; var cmd = new ConfigureOverdraftLimit { AccountId = _accountId, OverdraftLimit = overdraftLimit }; await _runner.Run( def => def.Given().When(cmd).Throws(new ValidationException("No account with this ID exists")) ); }
public async Task CannotConfigureNegativeOverdraftLimitOnAccount() { decimal overdraftLimit = -5000; var accountCreated = new AccountCreated(CorrelatedMessage.NewRoot()) { AccountId = _accountId, AccountHolderName = "Tushar" }; var cmd = new ConfigureOverdraftLimit { AccountId = _accountId, OverdraftLimit = overdraftLimit }; await _runner.Run( def => def.Given(accountCreated).When(cmd).Throws(new ValidationException("Overdraft limit must be positive")) ); }
public async Task CanConfigureOverdraftLimitOnAccount() { decimal overdraftLimit = 500; var accountCreated = new AccountCreated(CorrelatedMessage.NewRoot()) { AccountId = _accountId, AccountHolderName = "Tushar" }; var cmd = new ConfigureOverdraftLimit { AccountId = _accountId, OverdraftLimit = overdraftLimit }; var ev = new OverdraftLimitConfigured(cmd) { AccountId = cmd.AccountId, OverdraftLimit = cmd.OverdraftLimit }; await _runner.Run( def => def.Given(accountCreated).When(cmd).Then(ev) ); }