package com.flipper83.katapotter;

import java.util.ArrayList;
import java.util.List;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class BasketCalculatorTest {
  private static final List<String> EMPTY_BASKET = new ArrayList<>();
  private static final String FIRST_BOOK = "Philosopher stone";
  private static final String SECOND_BOOK = "The chamber of secrets";
  public static final int DELTA_ZERO = 0;

  @Test
  public void shouldReturnZeroPriceForAnEmptyBasket() {
    BasketCalculator basketCalculator = new BasketCalculator();

    float amount = basketCalculator.calculatePrice(EMPTY_BASKET);

    assertEquals(0, amount, DELTA_ZERO);
  }

  @Test
  public void shouldReturnPriceWithoutDiscountWithABasketWithOneBook() {
    BasketCalculator basketCalculator = new BasketCalculator();
    List<String> basket = givenBasketWithOneBook();

    float amount = basketCalculator.calculatePrice(basket);

    assertEquals(8, amount, DELTA_ZERO);
  }

  @Test
  public void shouldReturnPriceWithoutDiscountWithABasketWithTwoSameBooks() {
    BasketCalculator basketCalculator = new BasketCalculator();
    List<String> basket = givenBasketWithTwoSameBooks();

    float amount = basketCalculator.calculatePrice(basket);

    assertEquals(8 * 2, amount, DELTA_ZERO);
  }

  @Test
  public void shouldReturnPriceWithDiscountWithABasketWithTwoDifferentBooks() {
    BasketCalculator basketCalculator = new BasketCalculator();
    List<String> basket = givenBasketWithTwoDifferentBooks();

    float amount = basketCalculator.calculatePrice(basket);

    assertEquals(8 * 2 * 0.95f, amount, DELTA_ZERO);
  }

  private List<String> givenBasketWithTwoDifferentBooks() {
    List<String> basket = new ArrayList<>();
    basket.add(FIRST_BOOK);
    basket.add(SECOND_BOOK);
    return basket;
  }

  private List<String> givenBasketWithTwoSameBooks() {
    List<String> basket = new ArrayList<>();
    basket.add(FIRST_BOOK);
    basket.add(FIRST_BOOK);
    return basket;
  }

  private List<String> givenBasketWithOneBook() {
    List<String> basket = new ArrayList<>();
    basket.add(FIRST_BOOK);
    return basket;
  }
}
@@ -1700,303 +1700,277 @@
     
-List%3CString%3E basket = new ArrayList%3C%3E();%0A    basket.add(FIRST_BOOK);%0A    basket.add(SECOND_BOOK);%0A    return basket;%0A  %7D%0A%0A  private List%3CString%3E givenBasketWithTwoSameBooks() %7B%0A    List%3CString%3E basket = new ArrayList%3C%3E();%0A    basket.add(FIRST_BOOK);%0A    basket.add(FIRST_BOOK);%0A    return basket
+return givenBasketWithBooks(FIRST_BOOK, SECOND_BOOK);%0A  %7D%0A%0A  private List%3CString%3E givenBasketWithTwoSameBooks() %7B%0A    return givenBasketWithBooks(FIRST_BOOK, FIRST_BOOK);%0A  %7D%0A%0A  private List%3CString%3E givenBasketWithOneBook() %7B%0A    return givenBasketWithBooks(FIRST_BOOK)
 ;%0A  
@@ -2006,32 +2006,45 @@
 enBasketWith
-One
 Book
-(
+s(String... books
 ) %7B%0A    List
@@ -2088,31 +2088,102 @@
     
-basket.add(FIRST_BOOK);
+if (books != null) %7B%0A      for (String book : books) %7B%0A        basket.add(book);%0A      %7D%0A    %7D
 %0A   

Create method that provide basket for tests proposes.