public void TheTotalALogWithOnlyDebitsIsTheirNegativeSum()
        {
            var transactionLog = new Ledger();

            transactionLog.Record(new DebitEntry(DateTime.Now, new Money(1m)));
            transactionLog.Record(new DebitEntry(DateTime.Now, new Money(3m)));

            var actualTotal = transactionLog.Accept(new BalanceCalculatingVisitor(), new Money(0m));

            var expectedTotal = new Money(-4m);

            Assert.That(actualTotal, Is.EqualTo(expectedTotal));
        }
        public void TotalEqualsSumOfAddedMoney()
        {
            var transactionLog = new Ledger();

            transactionLog.Record(new CreditEntry(DateTime.Now, new Money(1m)));
            transactionLog.Record(new CreditEntry(DateTime.Now, new Money(3m)));

            var actualTotal = transactionLog.Accept(new BalanceCalculatingVisitor(), new Money(0m));

            var expectedTotal = new Money(4m);

            Assert.That(actualTotal, Is.EqualTo(expectedTotal));
        }
Ejemplo n.º 3
0
        public void WhenCashingInACheque_TheAmountShouldBeTakenOutOfTheAccount()
        {
            // ARRANGE
            var transactionLog = new Ledger();
            var expectedTotal  = new Money(-1m);

            // ACT
            transactionLog.Record(new ChequeWithdrawal(DateTime.Now, new Money(1m), new ChequeNumber(10)));

            // ASSERT
            var actualTotal = transactionLog.Accept(new BalanceCalculatingVisitor(), new Money(0m));

            Assert.That(actualTotal, Is.EqualTo(expectedTotal));
        }