コード例 #1
0
        public void can_apply_credit()
        {
            var accountId     = Guid.NewGuid();
            var correlationId = Guid.NewGuid();

            Bus.Fire(
                new CreateAccount(
                    accountId,
                    "NewAccount",
                    correlationId,
                    null),
                responseTimeout: TimeSpan.FromMilliseconds(3000));

            const double amountCredited = 123.45;

            Bus.Fire(new ApplyCredit(
                         accountId,
                         amountCredited,
                         correlationId,
                         Guid.Empty),
                     responseTimeout: TimeSpan.FromSeconds(60));

            BusCommands.DequeueNext <CreateAccount>();
            RepositoryEvents.DequeueNext <AccountCreated>();

            BusCommands.AssertNext <ApplyCredit>(correlationId, out var cmd)
            .AssertEmpty();

            RepositoryEvents.AssertNext <CreditApplied>(correlationId, out var evt)
            .AssertEmpty();

            Assert.Equal(amountCredited, evt.Amount);
        }
コード例 #2
0
        public void dropdown_determines_credit_or_debit()
        {
            var vm = new MainWindowViewModel(Bus, null, _accountId)
            {
                Amount = 100
            };

            vm.CreditOrDebitSelection = "Debit";
            vm.AddCreditOrDebitCommand.Execute();
            Assert.IsType <ApplyDebit>(BusCommands.First());

            vm.CreditOrDebitSelection = "Credit";
            vm.AddCreditOrDebitCommand.Execute();
            Assert.IsType <ApplyCredit>(BusCommands.Skip(1).First());
        }
コード例 #3
0
        public void can_apply_debit()
        {
            const double amountDebited = 123.45;

            Bus.Fire(new ApplyDebit(
                         _accountId,
                         amountDebited,
                         _correlationId,
                         Guid.Empty),
                     responseTimeout: TimeSpan.FromSeconds(60));

            BusCommands.AssertNext <ApplyDebit>(_correlationId, out var cmd)
            .AssertEmpty();

            RepositoryEvents.AssertNext <DebitApplied>(_correlationId, out var evt)
            .AssertEmpty();

            Assert.Equal(amountDebited, evt.Amount);
        }
コード例 #4
0
        public void can_create_account()
        {
            var accountId     = Guid.NewGuid();
            var correlationId = Guid.NewGuid();

            Bus.Fire(
                new CreateAccount(
                    accountId,
                    "NewAccount",
                    correlationId,
                    null),
                responseTimeout: TimeSpan.FromMilliseconds(1500));

            BusCommands.AssertNext <CreateAccount>(correlationId, out var cmd)
            .AssertEmpty();

            RepositoryEvents.AssertNext <AccountCreated>(correlationId, out var evt)
            .AssertEmpty();

            Assert.Equal(accountId, evt.AccountId);
        }