public async Task CanDepositCashInToValidAccount() { decimal depositeAmount = 5000; DateTime depositeDate = System.DateTime.Now; var accountCreated = new AccountCreated(CorrelatedMessage.NewRoot()) { AccountId = _accountId, AccountHolderName = "Tushar" }; var cmd = new DepositCash { AccountId = _accountId, DepositAmount = depositeAmount }; var ev = new CashDeposited(cmd) { AccountId = _accountId, DepositAmount = depositeAmount }; await _runner.Run( def => def.Given(accountCreated).When(cmd).Then(ev) ); }
public async Task CanWithdrawCash(decimal deposit, decimal withdraw) { var accCreatedEv = new AccountCreated(CorrelatedMessage.NewRoot()) { AccountId = _accountId, Name = "Jake Sanders" }; var depositedEv = new CashDeposited(CorrelatedMessage.NewRoot()) { AccountId = _accountId, Amount = deposit }; var cmd = new WithdrawCash() { AccountId = _accountId, Amount = withdraw }; var withdrawnEv = new CashWithdrawn(cmd) { AccountId = _accountId, Amount = cmd.Amount }; await _runner.Run( def => def .Given(accCreatedEv, depositedEv) .When(cmd) .Then(withdrawnEv)); }
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 CanCreateAccount() { var cmd = new CreateAccount { AccountId = _accountId, AccountHolderName = "John Doe" }; var ev = new AccountCreated(cmd) { AccountId = cmd.AccountId, AccountHolderName = cmd.AccountHolderName }; await _runner.Run( def => def.Given().When(cmd).Then(ev) ); }
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 CanWithdrawCashFromValidAccount() { decimal withdrawAmount = 5000; decimal depositeAmount = 5000; 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 cmd = new WithdrawCash() { AccountId = _accountId, WithdrawAmount = withdrawAmount }; var ev = new CashWithdrawn(cmd) { AccountId = _accountId, WithdrawAmount = withdrawAmount }; await _runner.Run( def => def.Given(accountCreated, evtCashDeposited).When(cmd).Then(ev) ); }
public async Task CanSetOverdraftLimit(decimal limit) { var accCreatedEv = new AccountCreated(CorrelatedMessage.NewRoot()) { AccountId = _accountId, Name = "Jake Sanders" }; var cmd = new SetOverdraftLimit { AccountId = _accountId, OverdraftLimit = limit }; var limitSetEv = new OverdraftLimitSet(CorrelatedMessage.NewRoot()) { AccountId = cmd.AccountId, OverdraftLimit = cmd.OverdraftLimit }; await _runner.Run( def => def.Given(accCreatedEv).When(cmd).Then(limitSetEv) ); }
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) ); }
public async Task CanConfigureDailyWireTransferLimitOnAccount() { decimal dailyWireTransferLimit = 5000; var accountCreated = new AccountCreated(CorrelatedMessage.NewRoot()) { AccountId = _accountId, AccountHolderName = "Tushar" }; var cmd = new ConfigureDailyWireTransferLimit { AccountId = _accountId, DailyWireTransferLimit = dailyWireTransferLimit }; var ev = new DailyWireTransferLimitConfigured(cmd) { AccountId = cmd.AccountId, DailyWireTransferLimit = cmd.DailyWireTransferLimit }; await _runner.Run( def => def.Given(accountCreated).When(cmd).Then(ev) ); }
public async Task CanDepositCash(double amount) { var created = new AccountCreated(CorrelatedMessage.NewRoot()) { AccountId = _accountId, AccountHolderName = "Parth Sheth" }; var cmd = new DepositCash { AccountId = _accountId, Amount = Convert.ToDecimal(amount) }; var limitSet = new CashDeposited(cmd) { AccountId = _accountId, Amount = cmd.Amount }; await _runner.Run( def => def.Given(created).When(cmd).Then(limitSet) ); }
public async Task CanDepositCheque(decimal amount) { var accCreatedEv = new AccountCreated(CorrelatedMessage.NewRoot()) { AccountId = _accountId, Name = "Jake Sanders" }; var cmd = new DepositCheque() { AccountId = _accountId, Amount = amount }; var amountSetEv = new ChequeDeposited(CorrelatedMessage.NewRoot()) { AccountId = cmd.AccountId, Amount = cmd.Amount }; await _runner.Run( def => def.Given(accCreatedEv).When(cmd).Then(amountSetEv) ); }
public async Task CanSetDailyWireTransferLimit(double limit) { var created = new AccountCreated(CorrelatedMessage.NewRoot()) { AccountId = _accountId, AccountHolderName = "Parth Sheth" }; var cmd = new SetDailyWireTransferLimit { AccountId = _accountId, DailyWireTransferLimit = Convert.ToDecimal(limit) }; var limitSet = new DailyWireTransferLimitSet(cmd) { AccountId = _accountId, DailyWireTransferLimit = cmd.DailyWireTransferLimit }; await _runner.Run( def => def.Given(created).When(cmd).Then(limitSet) ); }
public async Task CanWireTransferIfEnoughFundsAndNotExceededLimits( decimal deposit, decimal limit, decimal transfer) { var accCreatedEv = new AccountCreated(CorrelatedMessage.NewRoot()) { AccountId = _accountId, Name = "Jake Sanders" }; var cashDepositedEv = new CashDeposited(CorrelatedMessage.NewRoot()) { AccountId = _accountId, Amount = deposit }; var dailyLimitSetEv = new DailyWireTransferLimitSet(CorrelatedMessage.NewRoot()) { AccountId = _accountId, DailyLimit = limit }; var cmd = new TryWireTransfer() { AccountId = _accountId, Amount = transfer }; var transferedEv = new WireTransferHappened(CorrelatedMessage.NewRoot()) { AccountId = _accountId, Amount = cmd.Amount }; await _runner.Run( def => def .Given(accCreatedEv, cashDepositedEv, dailyLimitSetEv) .When(cmd) .Then(transferedEv)); }
public async Task CanTransferFundFromValidAccount() { decimal WireTransferFund = 5000; decimal depositeAmount = 5000; 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 cmd = new TransferWireFund() { AccountId = _accountId, WireFund = WireTransferFund }; var ev = new WireFundTransferred(cmd) { AccountId = _accountId, WireFund = WireTransferFund }; await _runner.Run( def => def.Given(accountCreated, evtCashDeposited).When(cmd).Then(ev) ); }