|
@ -29,20 +29,19 @@ public class ItemTest extends TestCase { |
|
|
// Given |
|
|
// Given |
|
|
Item item = new Item(); |
|
|
Item item = new Item(); |
|
|
int quantity = 3; |
|
|
int quantity = 3; |
|
|
int price = 5; |
|
|
|
|
|
|
|
|
float price = 5; |
|
|
item.updateAvailability(quantity); |
|
|
item.updateAvailability(quantity); |
|
|
item.updatePrice(price); |
|
|
item.updatePrice(price); |
|
|
|
|
|
|
|
|
// When |
|
|
// When |
|
|
int expectedPrice = quantity * price; |
|
|
|
|
|
|
|
|
float expectedPrice = quantity * price; |
|
|
|
|
|
|
|
|
// Then |
|
|
// Then |
|
|
int actualPrice = 0; |
|
|
|
|
|
|
|
|
float actualPrice = 0; |
|
|
for(int i = 0; i < quantity; i++) { |
|
|
for(int i = 0; i < quantity; i++) { |
|
|
actualPrice += item.getCurrentPrice(); |
|
|
actualPrice += item.getCurrentPrice(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(expectedPrice, actualPrice); |
|
|
assertEquals(expectedPrice, actualPrice); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |