Esempio n. 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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }