Exemplo n.º 1
0
        public async Task CanUnblockAccountOnNextBusinessDay()
        {
            var accCreatedEv = new AccountCreated(CorrelatedMessage.NewRoot())
            {
                AccountId = _accountId,
                Name      = "Jake Sanders"
            };

            var accBlockedEv = new AccountBlocked(CorrelatedMessage.NewRoot())
            {
                AccountId = _accountId
            };

            var depositedEv = new ChequeDeposited(CorrelatedMessage.NewRoot())
            {
                AccountId = _accountId,
                Amount    = 1000m
            };

            var cmd = new StartNewBusinessDay()
            {
                AccountId = _accountId
            };

            var accUnblockedEv = new AccountUnblocked(CorrelatedMessage.NewRoot())
            {
                AccountId = _accountId
            };

            await _runner.Run(
                def => def
                .Given(accCreatedEv, accBlockedEv, depositedEv)
                .When(cmd)
                .Then(accUnblockedEv));
        }
Exemplo n.º 2
0
        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)
                );
        }
Exemplo n.º 3
0
        public async Task CanUnblockAccount()
        {
            var accCreatedEv = new AccountCreated(CorrelatedMessage.NewRoot())
            {
                AccountId = _accountId,
                Name      = "Jake Sanders"
            };

            var accBlockedEv = new AccountBlocked(CorrelatedMessage.NewRoot())
            {
                AccountId = _accountId
            };

            var cmd = new DepositCash()
            {
                AccountId = _accountId,
                Amount    = 1000
            };

            var amountSetEv = new CashDeposited(CorrelatedMessage.NewRoot())
            {
                AccountId = cmd.AccountId,
                Amount    = cmd.Amount
            };

            var accUnblockedEv = new AccountUnblocked(CorrelatedMessage.NewRoot())
            {
                AccountId = _accountId
            };

            await _runner.Run(
                def => def
                .Given(accCreatedEv, accBlockedEv)
                .When(cmd)
                .Then(amountSetEv, accUnblockedEv));
        }
Exemplo n.º 4
0
 private void Apply(AccountUnblocked @event)
 {
     AccountState = State.unblocked;
 }