mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
extract Aged Brie tests, verify that The Quality of an item is never more than 50
This commit is contained in:
parent
41ebe9f98e
commit
1b72b9b937
@ -0,0 +1,48 @@
|
||||
package com.gildedrose;
|
||||
|
||||
import io.qameta.allure.Feature;
|
||||
import lombok.val;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import static com.gildedrose.TestHelper.assertItem;
|
||||
import static com.gildedrose.TestHelper.prepareApp;
|
||||
import static java.lang.Math.min;
|
||||
import static org.apache.commons.lang3.RandomUtils.nextInt;
|
||||
|
||||
|
||||
class GildedRoseAgedBrieTest {
|
||||
|
||||
@Feature("The Quality of an item is never more than 50")
|
||||
@ParameterizedTest(name = "Initial quality: {arguments}")
|
||||
@ValueSource(ints = {49, 50})
|
||||
void shouldNotIncreaseQualityAbove50(int initialQuality) {
|
||||
// given
|
||||
val initialSellIn = nextInt(3, 50);
|
||||
GildedRose app = prepareApp(new Item("Aged Brie", initialSellIn, initialQuality));
|
||||
|
||||
// when
|
||||
app.updateQuality();
|
||||
|
||||
// then
|
||||
final Item item = app.items[0];
|
||||
assertItem(item, "Aged Brie", initialSellIn - 1, 50);
|
||||
}
|
||||
|
||||
@Feature("\"Aged Brie\" actually increases in Quality the older it gets")
|
||||
@Feature("The Quality of an item is never more than 50")
|
||||
@ParameterizedTest(name = "Initial quality: {arguments}")
|
||||
@ValueSource(ints = {0, 1, 49, 50})
|
||||
void shouldIncreaseQualityForAgedBrie(int initialQuality) {
|
||||
// given
|
||||
GildedRose app = prepareApp(new Item("Aged Brie", 1, initialQuality));
|
||||
|
||||
// when
|
||||
app.updateQuality();
|
||||
|
||||
// then
|
||||
final Item item = app.items[0];
|
||||
final int expectedQuality = min(initialQuality + 1, 50);
|
||||
assertItem(item, "Aged Brie", 0, expectedQuality);
|
||||
}
|
||||
}
|
||||
@ -8,25 +8,11 @@ import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import static com.gildedrose.TestHelper.assertItem;
|
||||
import static com.gildedrose.TestHelper.prepareApp;
|
||||
import static java.lang.Math.min;
|
||||
import static org.apache.commons.lang3.RandomUtils.nextInt;
|
||||
|
||||
|
||||
class GildedRoseTest {
|
||||
|
||||
@Test
|
||||
void shouldProcessFooItem() {
|
||||
// given
|
||||
GildedRose app = prepareApp(new Item("foo", 0, 0));
|
||||
|
||||
// when
|
||||
app.updateQuality();
|
||||
|
||||
// then
|
||||
final Item item = app.items[0];
|
||||
assertItem(item, "foo", -1, 0);
|
||||
}
|
||||
|
||||
@Feature("The Quality of an item is never negative")
|
||||
@ParameterizedTest(name = "Initial quality: {arguments}")
|
||||
@ValueSource(ints = {0, 1})
|
||||
@ -74,21 +60,4 @@ class GildedRoseTest {
|
||||
final Item item = app.items[0];
|
||||
assertItem(item, itemName, initialSellIn, initialQuality);
|
||||
}
|
||||
|
||||
@Feature("\"Aged Brie\" actually increases in Quality the older it gets")
|
||||
@Feature("The Quality of an item is never more than 50")
|
||||
@ParameterizedTest(name = "Initial quality: {arguments}")
|
||||
@ValueSource(ints = {0, 1, 49, 50})
|
||||
void shouldIncreaseQualityForAgedBrie(int initialQuality) {
|
||||
// given
|
||||
GildedRose app = prepareApp(new Item("Aged Brie", 1, initialQuality));
|
||||
|
||||
// when
|
||||
app.updateQuality();
|
||||
|
||||
// then
|
||||
final Item item = app.items[0];
|
||||
final int expectedQuality = min(initialQuality + 1, 50);
|
||||
assertItem(item, "Aged Brie", 0, expectedQuality);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user