public void Should_Different_Plus() { MoneyExpression sum = Money.Dollar(5).Plus(Money.Franc(10)); Bank bank = new Bank(); bank.AddRate("CHF", "USD", 2); Assert.AreEqual(Money.Dollar(10), sum.Reduce(bank, USD)); }
public void Test_Sum_Times() { 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.AreEqual(Money.Dollar(20), result); }
public MoneyExpression Plus(MoneyExpression addend) => new SumExpression(this, addend);
public SumExpression(MoneyExpression augend, MoneyExpression addend) { Augend = augend; Addend = addend; }
public MoneyExpression Plus(MoneyExpression fiveBucks) { return(new Sum(this, addend)); }
public Sum(MoneyExpression augend, MoneyExpression addend) { this.augend = augend; this.addend = addend; }
public Money Reduce(MoneyExpression source, string to) => source.Reduce(this, to);
public Money Reduce(MoneyExpression source, string to) { return(source.Reduce(this, to)); }