コード例 #1
0
  @Test
  public void should_calculate_total_when_given_1_item() {
    List<CartItem> emptyCart = Arrays.asList(new CartItem("ITEM000003", 1));
    double total = posMachine.calculate(emptyCart);

    assertThat(total, is(50d));
  }
コード例 #2
0
  @Test
  public void should_calculate_total_when_given_multiple_items_in_second_half_price() {
    List<CartItem> emptyCart = Arrays.asList(new CartItem("ITEM000003", 3));
    double total = posMachine.calculate(emptyCart);

    assertThat(total, is(125d));
  }
コード例 #3
0
  @Test
  public void should_return_0_when_shopping_cart_empty() {
    List<CartItem> emptyCart = Arrays.asList();
    double total = posMachine.calculate(emptyCart);

    assertThat(total, is(0d));
  }
コード例 #4
0
  @Test
  public void should_calculate_total_when_item3_has_second_half_price() throws Exception {
    List<CartItem> itemCart = Arrays.asList(new CartItem("ITEM000003", 2));
    double total = posMachine.calculate(itemCart);
    System.out.println(total);

    assertThat(total, is(75d));
  }
コード例 #5
0
  @Test
  public void should_calculate_total_when_item5_has_discount() throws Exception {
    List<CartItem> itemCart = Arrays.asList(new CartItem("ITEM000005", 3));
    double total = posMachine.calculate(itemCart);
    System.out.println(total);

    assertThat(total, is(162d));
  }