mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
add parameterized test
This commit is contained in:
parent
8ab2ff61df
commit
2baced7d94
@ -1,19 +1,30 @@
|
|||||||
package com.gildedrose;
|
package com.gildedrose;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
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;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
class GildedRoseTest {
|
class GildedRoseTest {
|
||||||
|
|
||||||
@Test
|
private static Stream<Arguments> provideInputWhereSellInDayPassesByOneDay() {
|
||||||
void shouldDegradeQualityForAnItem() {
|
|
||||||
Item[] items = new Item[]{new Item("Normal Item", 0, 0)};
|
return Stream.of(
|
||||||
GildedRose app = new GildedRose(items);
|
Arguments.of(new GildedRose(new Item[]{new Item("Normal Item", 0, 0)}), "Normal Item", -1, 0)
|
||||||
app.updateQuality();
|
);
|
||||||
assertEquals("Normal Item", app.items[0].name);
|
}
|
||||||
assertEquals(-1, app.items[0].sellIn);
|
|
||||||
assertEquals(0, app.items[0].quality);
|
@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