mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 06:21:29 +00:00
backstage rule for 10+ days
This commit is contained in:
parent
6b5deb7880
commit
f23572d512
@ -17,8 +17,10 @@ public class BackstagePassQualityRule implements QualityRule {
|
|||||||
newQuality = 0;
|
newQuality = 0;
|
||||||
} else if (sellIn < 5) {
|
} else if (sellIn < 5) {
|
||||||
newQuality = oldQuality + 3;
|
newQuality = oldQuality + 3;
|
||||||
} else {
|
} else if (sellIn < 10) {
|
||||||
newQuality = oldQuality + 2;
|
newQuality = oldQuality + 2;
|
||||||
|
} else {
|
||||||
|
newQuality = oldQuality + 1;
|
||||||
}
|
}
|
||||||
return new Result(min(newQuality, 50), true);
|
return new Result(min(newQuality, 50), true);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,23 @@ class GildedRoseBackstageTest {
|
|||||||
|
|
||||||
private static final String ITEM_NAME = "Backstage passes to a TAFKAL80ETC concert";
|
private static final String ITEM_NAME = "Backstage passes to a TAFKAL80ETC concert";
|
||||||
|
|
||||||
|
@Feature("Quality increases by 1 when there are more than 10 days")
|
||||||
|
@ParameterizedTest(name = "sellIn: {arguments}")
|
||||||
|
@ValueSource(ints = {112, 11})
|
||||||
|
void shouldIncreaseQualityWhenThereAreMoreThan10Days(int sellIn) {
|
||||||
|
// given
|
||||||
|
val initialQuality = nextInt(10, 40);
|
||||||
|
GildedRose app = prepareApp(new Item(ITEM_NAME, sellIn, initialQuality));
|
||||||
|
|
||||||
|
// when
|
||||||
|
app.updateQuality();
|
||||||
|
|
||||||
|
// then
|
||||||
|
final Item item = app.items[0];
|
||||||
|
assertItem(item, ITEM_NAME, sellIn - 1, initialQuality + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Feature("Quality increases by 2 when there are 10 days or less")
|
@Feature("Quality increases by 2 when there are 10 days or less")
|
||||||
@ParameterizedTest(name = "sellIn: {arguments}")
|
@ParameterizedTest(name = "sellIn: {arguments}")
|
||||||
@ValueSource(ints = {10, 9, 8, 7, 6})
|
@ValueSource(ints = {10, 9, 8, 7, 6})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user