Ejemplo n.º 1
0
        public async Task CannotWireTransferMultipleTimesIfLimitExceeded(
            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 transferedEv = new WireTransferHappened(CorrelatedMessage.NewRoot())
            {
                AccountId = _accountId,
                Amount    = transfer
            };

            var cmd = new TryWireTransfer()
            {
                AccountId = _accountId,
                Amount    = transfer
            };

            var transferFailedEv = new WireTransferFailed(CorrelatedMessage.NewRoot())
            {
                AccountId = _accountId,
                Amount    = transfer
            };

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

            await _runner.Run(
                def => def
                .Given(accCreatedEv, cashDepositedEv, dailyLimitSetEv, transferedEv, transferedEv)
                .When(cmd)
                .Then(transferFailedEv, accBlockedEv));
        }
Ejemplo n.º 2
0
        public async Task CannotWireTransferIfAccountIsBlocked()
        {
            var deposit  = 5000m;
            var transfer = 100m;

            var accCreatedEv = new AccountCreated(CorrelatedMessage.NewRoot())
            {
                AccountId = _accountId,
                Name      = "Jake Sanders"
            };

            var cashDepositedEv = new CashDeposited(CorrelatedMessage.NewRoot())
            {
                AccountId = _accountId,
                Amount    = deposit
            };

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

            var cmd = new TryWireTransfer()
            {
                AccountId = _accountId,
                Amount    = transfer
            };

            var transferFailedEv = new WireTransferFailed(CorrelatedMessage.NewRoot())
            {
                AccountId = _accountId,
                Amount    = cmd.Amount
            };

            await _runner.Run(
                def => def
                .Given(accCreatedEv, cashDepositedEv, accBlocked)
                .When(cmd)
                .Then(transferFailedEv));
        }