public async Task ShouldUnblockOnCashDepositWhenAccountIsAlreadyBlocked() { decimal depositeAmount = 5000; decimal overdraftLimit = 1000; decimal withdrawAmount = 7000; var accountCreated = new AccountCreated(CorrelatedMessage.NewRoot()) { AccountId = _accountId, AccountHolderName = "Tushar" }; var evtCashDeposited = new CashDeposited(CorrelatedMessage.NewRoot()) { AccountId = _accountId, DepositAmount = depositeAmount }; var evOverdraftLimitConfigured = new OverdraftLimitConfigured(CorrelatedMessage.NewRoot()) { AccountId = _accountId, OverdraftLimit = overdraftLimit }; var evtCashWithdrawn = new CashWithdrawn(CorrelatedMessage.NewRoot()) { AccountId = _accountId, WithdrawAmount = withdrawAmount }; var evAccountBlocked = new AccountBlocked(CorrelatedMessage.NewRoot()) { AccountId = _accountId, Amount = withdrawAmount }; var cmd = new DepositCash() { AccountId = _accountId, DepositAmount = depositeAmount }; var evAccountUnblocked = new AccountUnblocked(CorrelatedMessage.NewRoot()) { AccountId = _accountId, Amount = depositeAmount }; //Yet to decide how to tackle this. await _runner.Run( def => def.Given(accountCreated, evtCashDeposited, evOverdraftLimitConfigured, evtCashWithdrawn, evAccountBlocked).When(cmd).Then(evAccountUnblocked) ); }
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 CannotWithdrawCashOutsideBalanceAndWithOverdraftLimit() { decimal depositeAmount = 5000; decimal overdraftLimit = 1000; 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 evOverdraftLimitConfigured = new OverdraftLimitConfigured(CorrelatedMessage.NewRoot()) { AccountId = _accountId, OverdraftLimit = overdraftLimit }; var cmd = new WithdrawCash() { AccountId = _accountId, WithdrawAmount = withdrawAmount }; var evAccountBlocked = new AccountBlocked(CorrelatedMessage.NewRoot()) { AccountId = _accountId, Amount = withdrawAmount }; await _runner.Run( def => def.Given(accountCreated, evtCashDeposited, evOverdraftLimitConfigured).When(cmd).Then(evAccountBlocked) ); }
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) ); }