Ajout de tests paramétrés sur Rental
All checks were successful
Gradle Test / test (push) Successful in 1m9s
All checks were successful
Gradle Test / test (push) Successful in 1m9s
This commit is contained in:
parent
73de7805c6
commit
a95bf5e7a2
1 changed files with 31 additions and 0 deletions
31
src/test/java/movierental/RentalTest.java
Normal file
31
src/test/java/movierental/RentalTest.java
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
package movierental;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.CsvSource;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class RentalTest {
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@CsvSource({
|
||||||
|
"2, 0, 2.0", // regular movie, no overtime
|
||||||
|
"3, 0, 3.5", // regular movie, with overtime
|
||||||
|
"1, 1, 3.0", // new release movie, one day
|
||||||
|
"2, 1, 6.0", // new release movie, two days
|
||||||
|
"3, 2, 1.5", // children movie, no overtime
|
||||||
|
"4, 2, 3.0" // children movie, with overtime
|
||||||
|
})
|
||||||
|
void should_return_correct_price_for_movie(int daysRented, int movie_type, double expected) {
|
||||||
|
// Given
|
||||||
|
Movie movie = new Movie("Mock Movie", movie_type);
|
||||||
|
Rental rental = new Rental(movie, daysRented);
|
||||||
|
|
||||||
|
// When
|
||||||
|
double price = rental.calculatePrice();
|
||||||
|
|
||||||
|
// Then
|
||||||
|
assertEquals(expected, price);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue