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); }
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); }
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); }
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); }
public MoneyExpression Plus(MoneyExpression addend) { return(new Sum(this, addend)); }
public Money Reduce(MoneyExpression source, string to) { return(source.Reduce(this, to)); }
public Sum(MoneyExpression augend, MoneyExpression addend) { this.augend = augend; this.addend = addend; }