Skip to content

Commit

Permalink
added test for rental charges logic
Browse files Browse the repository at this point in the history
  • Loading branch information
moloch committed Apr 11, 2014
1 parent 0f3ed86 commit 5964461
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions test/refactoring/RentalTest.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
package refactoring;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class RentalTest {

@Test
public void testGetDaysRented() {
fail("Not yet implemented");
}
public void testGetCharge() {
assertEquals(2, getChargeForMovie(Movie.REGULAR, 2), 0.01);
assertEquals(3.5, getChargeForMovie(Movie.REGULAR, 3), 0.01);
assertEquals(5, getChargeForMovie(Movie.REGULAR, 4), 0.01);
assertEquals(6.5, getChargeForMovie(Movie.REGULAR, 5), 0.01);
assertEquals(9, getChargeForMovie(Movie.NEW_RELEASE, 3), 0.01);
assertEquals(12, getChargeForMovie(Movie.NEW_RELEASE, 4), 0.01);
assertEquals(15, getChargeForMovie(Movie.NEW_RELEASE, 5), 0.01);
assertEquals(1.5, getChargeForMovie(Movie.CHILDRENS, 3), 0.01);
assertEquals(3, getChargeForMovie(Movie.CHILDRENS, 4), 0.01);
assertEquals(4.5, getChargeForMovie(Movie.CHILDRENS, 5), 0.01);

@Test
public void testGetMovie() {
fail("Not yet implemented");
}

private double getChargeForMovie(int type, int days) {
return new Rental(new Movie("", type), days).getCharge();
}
}

0 comments on commit 5964461

Please sign in to comment.