Ejemplo n.º 1
0
 @Test
 public void testReduceSum() {
   Expression sum = new Sum(Money.dollar(3), Money.dollar(4));
   Bank bank = new Bank();
   Money result = bank.reduce(sum, "USD");
   assertEquals(Money.dollar(7), result);
 }
Ejemplo n.º 2
0
 @Test
 public void testReduceMoneyDifferentCurrency() {
   Bank bank = new Bank();
   bank.addRate("CHF", "USD", 2);
   Money result = bank.reduce(Money.franc(2), "USD");
   assertEquals(Money.dollar(1), result);
 }
Ejemplo n.º 3
0
 @Test
 public void testAddition() {
   Money five = Money.dollar(5);
   Expression sum = five.plus(five);
   Bank bank = new Bank();
   Money reduced = bank.reduce(sum, "USD");
   assertEquals(Money.dollar(10), reduced);
 }
Ejemplo n.º 4
0
  public void testMixedAddition() {
    Expression fiveBucks = Money.dollar(5);
    Expression tenFrancs = Money.franc(10);

    Bank bank = new Bank();
    bank.addRate("CHF", "USD", 2);
    Money result = bank.reduce(fiveBucks.plus(tenFrancs), "USD");
    assertEquals(Money.dollar(10), result);
  }
Ejemplo n.º 5
0
  @Test
  public void testSumTimes() {
    Expression fiveBucks = Money.dollar(5);
    Expression tenFranks = Money.franc(10);
    Bank bank = new Bank();
    bank.addRate("CHF", "USD", 2);

    Expression sum = new Sum(fiveBucks, tenFranks).times(2);
    Money result = bank.reduce(sum, "USD");
    assertEquals(Money.dollar(20), result);
  }
Ejemplo n.º 6
0
 @Test
 public void testReduceMoney() {
   Bank bank = new Bank();
   Money result = bank.reduce(Money.dollar(1), "USD");
   assertEquals(Money.dollar(1), result);
 }