Пример #1
0
 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);
 }
Пример #2
0
 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);
 }
Пример #3
0
 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);
 }
Пример #4
0
 public Money Reduce(Bank bank, string to)
 {
     int rate = bank.Rate(_currency, to);
     return new Money(_amount / rate, to);
 }
Пример #5
0
 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);
 }
Пример #6
0
 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);
 }
Пример #7
0
 public void ReduceMoneyTest()
 {
     Bank bank = new Bank();
     Money result = bank.Reduce(Money.Dollar(1), "USD");
     Assert.AreEqual(Money.Dollar(1), result);
 }