Пример #1
0
        public void TestPlusReturnsSum()
        {
            Money           five   = Money.Dollar(5);
            MoneyExpression result = five.Plus(five);
            Sum             sum    = (Sum)result;

            Assert.Equal(five, sum.augend);
            Assert.Equal(five, sum.addend);
        }
Пример #2
0
        public void TestSimpleAddition()
        {
            Money           five    = Money.Dollar(5);
            MoneyExpression sum     = five.Plus(five);
            Bank            bank    = new Bank();
            Money           reduced = bank.Reduce(sum, "USD");

            Assert.Equal(Money.Dollar(10), reduced);
        }
Пример #3
0
        public void TestMixedAddition()
        {
            MoneyExpression fiveBucks = Money.Dollar(5);
            MoneyExpression tenFrancs = Money.Franc(10);
            Bank            bank      = new Bank();

            bank.AddRate("CHF", "USD", 2);
            Money result = bank.Reduce(fiveBucks.Plus(tenFrancs), "USD");

            Assert.Equal(Money.Dollar(10), result);
        }
Пример #4
0
        public void TestSumTimes()
        {
            MoneyExpression fiveBucks = Money.Dollar(5);
            MoneyExpression tenFrancs = Money.Franc(10);
            Bank            bank      = new Bank();

            bank.AddRate("CHF", "USD", 2);
            MoneyExpression sum    = new Sum(fiveBucks, tenFrancs).Times(2);
            Money           result = bank.Reduce(sum, "USD");

            Assert.Equal(Money.Dollar(20), result);
        }
Пример #5
0
 public MoneyExpression Plus(MoneyExpression addend)
 {
     return(new Sum(this, addend));
 }
Пример #6
0
 public Money Reduce(MoneyExpression source, string to)
 {
     return(source.Reduce(this, to));
 }
Пример #7
0
 public Sum(MoneyExpression augend, MoneyExpression addend)
 {
     this.augend = augend;
     this.addend = addend;
 }