public void ReduceMoneyDifferentCurrencyTest() { Bank bank = new Bank(); bank.AddRate("CHF", "USD", 2); Money result = bank.Reduce(Money.Franc(2), "USD"); Assert.AreEqual(Money.Dollar(1), result); }
public void ReduceSumTest() { IExpression sum = new Sum(Money.Dollar(3), Money.Dollar(4)); Bank bank = new Bank(); Money result = bank.Reduce(sum, "USD"); Assert.AreEqual(Money.Dollar(7), result); }
public void SimpleAdditionTest() { Money five = Money.Dollar(5); IExpression sum = five.Plus(five); Bank bank = new Bank(); Money reduced = bank.Reduce(sum, "USD"); Assert.AreEqual(Money.Dollar(10), reduced); }
public Money Reduce(Bank bank, string to) { int rate = bank.Rate(_currency, to); return new Money(_amount / rate, to); }
public void SumPlusMoneyTest() { IExpression fiveBucks = Money.Dollar(5); IExpression tenFrans = Money.Franc(10); Bank bank = new Bank(); bank.AddRate("CHF", "USD", 2); IExpression sum = new Sum(fiveBucks, tenFrans).Plus(fiveBucks); Money result = bank.Reduce(sum, "USD"); Assert.AreEqual(Money.Dollar(15), result); }
public void MixedAdditionTest() { IExpression fiveBucks = Money.Dollar(5); IExpression tenFrans = Money.Franc(10); Bank bank = new Bank(); bank.AddRate("CHF", "USD", 2); Money result = bank.Reduce(fiveBucks.Plus(tenFrans), "USD"); Assert.AreEqual(Money.Dollar(10), result); }
public void ReduceMoneyTest() { Bank bank = new Bank(); Money result = bank.Reduce(Money.Dollar(1), "USD"); Assert.AreEqual(Money.Dollar(1), result); }