mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
add parameterized test
This commit is contained in:
parent
8ab2ff61df
commit
2baced7d94
@ -1,19 +1,30 @@
|
||||
package com.gildedrose;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class GildedRoseTest {
|
||||
|
||||
@Test
|
||||
void shouldDegradeQualityForAnItem() {
|
||||
Item[] items = new Item[]{new Item("Normal Item", 0, 0)};
|
||||
GildedRose app = new GildedRose(items);
|
||||
app.updateQuality();
|
||||
assertEquals("Normal Item", app.items[0].name);
|
||||
assertEquals(-1, app.items[0].sellIn);
|
||||
assertEquals(0, app.items[0].quality);
|
||||
private static Stream<Arguments> provideInputWhereSellInDayPassesByOneDay() {
|
||||
|
||||
return Stream.of(
|
||||
Arguments.of(new GildedRose(new Item[]{new Item("Normal Item", 0, 0)}), "Normal Item", -1, 0)
|
||||
);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideInputWhereSellInDayPassesByOneDay")
|
||||
void shouldDegradeQualityForAnItem(GildedRose gildedRose, String expectedName, int expectedSellIn, int expectedQuality) {
|
||||
gildedRose.updateQuality();
|
||||
assertEquals(expectedName, gildedRose.items[0].name);
|
||||
assertEquals(expectedSellIn, gildedRose.items[0].sellIn);
|
||||
assertEquals(expectedQuality, gildedRose.items[0].quality);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user