예제 #1
0
  @Theory
  public void test(Fixture fixture1, Fixture fixture2) {
    // 【テスト条件のセットアップ】
    if (fixture1 != null) {
      sut.addRental(fixture1.rental);
    }
    if (fixture2 != null) {
      sut.addRental(fixture2.rental);
    }

    // 【テスト実施】
    String result = sut.statement();

    // 【テスト結果の検証】
    // 期待値作成
    String expected = "Rental Record for " + CUSTOMER_NAME + "\n";
    expected += buildAmountPartString(fixture1);
    expected += buildAmountPartString(fixture2);
    double totalAmount = calcTotalAmount(fixture1, fixture2);
    expected += "Amount owed is " + String.valueOf(totalAmount) + "\n";
    int frequentREnterPoints = calcPoint(fixture1, fixture2);
    expected += "You earned " + String.valueOf(frequentREnterPoints) + " frequent renter points";

    assertThat(result, is(expected));
  }
예제 #2
0
 @Test
 public void testWithOneOfEachTypeOfMovieFor3Days_ShouldGenerateComplexStatement() {
   Movie ironman = new Movie("Iron Man", Movie.REGULAR);
   customer.addRental(new Rental(ironman, 3));
   Movie irongiant = new Movie("Iron Giant", Movie.CHILDRENS);
   customer.addRental(new Rental(irongiant, 3));
   Movie ironman2 = new Movie("Iron Man 2", Movie.NEW_RELEASE);
   customer.addRental(new Rental(ironman2, 3));
   assertEquals(
       "Rental Record for Ryan\n"
           + "\tIron Man\t3.5\n"
           + "\tIron Giant\t1.5\n"
           + "\tIron Man 2\t9.0\n"
           + "Amount owed is 14.0\n"
           + "You earned 4 frequent renters points",
       customer.statement());
 }
예제 #3
0
 @Test
 public void testWithOneNewReleaseMovie_ShouldGenerateSimpleStatement() {
   Movie ironman = new Movie("Iron Man 2", Movie.NEW_RELEASE);
   Rental sunday = new Rental(ironman, 2);
   customer.addRental(sunday);
   assertEquals(
       "Rental Record for Ryan\n"
           + "\tIron Man 2\t6.0\n"
           + "Amount owed is 6.0\n"
           + "You earned 2 frequent renters points",
       customer.statement());
 }
예제 #4
0
 @Test
 public void testWithOneChildrensMovie_ShouldGenerateSimpleStatement() {
   Movie irongiant = new Movie("Iron Giant", Movie.CHILDRENS);
   Rental sunday = new Rental(irongiant, 2);
   customer.addRental(sunday);
   assertEquals(
       "Rental Record for Ryan\n"
           + "\tIron Giant\t1.5\n"
           + "Amount owed is 1.5\n"
           + "You earned 1 frequent renters points",
       customer.statement());
 }
예제 #5
0
 @Test
 public void testWithOneRegularMovie_ShouldGenerateSimpleStatement() {
   Movie ironman = new Movie("Iron Man", Movie.REGULAR);
   Rental sunday = new Rental(ironman, 2);
   customer.addRental(sunday);
   assertEquals(
       "Rental Record for Ryan\n"
           + "\tIron Man\t2.0\n"
           + "Amount owed is 2.0\n"
           + "You earned 1 frequent renters points",
       customer.statement());
 }