public void SuccessfulWithdrawUpdatesFromAccount([Values(1, 2000, 4000)] decimal amount)
        {
            withdrawMoney.Execute(
                TestAccountFactory.Ids.DefaultFrom,
                amount);

            // Ensure that the account is updated
            AccountRepositoryMock.Verify(x => x.Update(It.IsAny <Account>()), Times.Exactly(1));

            UpdatedAccounts.TryGetValue(TestAccountFactory.Ids.DefaultFrom, out var fromAfter).Should().BeTrue();

            // Ensure that the from balance and withdrawn properties have correct values after the withdrawal
            fromAfter.Balance.Should().Be(TestAccountFactory.DefaultBalance - amount);
            fromAfter.Withdrawn.Should().Be(TestAccountFactory.DefaultWithdrawn - amount);
        }
示例#2
0
        public void SuccessfulTransferUpdatesFromAndToAccounts([Values(1, 2000, 4000)] decimal amount)
        {
            transferMoney.Execute(
                TestAccountFactory.Ids.DefaultFrom,
                TestAccountFactory.Ids.DefaultTo,
                amount);

            // Ensure that both accounts are updated
            AccountRepositoryMock.Verify(x => x.Update(It.IsAny <Account>()), Times.Exactly(2));

            UpdatedAccounts.TryGetValue(TestAccountFactory.Ids.DefaultFrom, out var fromAfter).Should().BeTrue();
            UpdatedAccounts.TryGetValue(TestAccountFactory.Ids.DefaultTo, out var toAfter).Should().BeTrue();

            // Ensure that the balance and withdrawn properties have correct values after the transfer
            fromAfter.Balance.Should().Be(TestAccountFactory.DefaultBalance - amount);
            fromAfter.Withdrawn.Should().Be(TestAccountFactory.DefaultWithdrawn - amount);
            toAfter.Balance.Should().Be(TestAccountFactory.DefaultBalance + amount);
        }