backstage rule for 10+ days

This commit is contained in:
Konstantin Pavlov 2019-06-30 06:54:14 +02:00
parent 6b5deb7880
commit f23572d512
2 changed files with 20 additions and 1 deletions

View File

@ -17,8 +17,10 @@ public class BackstagePassQualityRule implements QualityRule {
newQuality = 0;
} else if (sellIn < 5) {
newQuality = oldQuality + 3;
} else {
} else if (sellIn < 10) {
newQuality = oldQuality + 2;
} else {
newQuality = oldQuality + 1;
}
return new Result(min(newQuality, 50), true);
}

View File

@ -18,6 +18,23 @@ class GildedRoseBackstageTest {
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")
@ParameterizedTest(name = "sellIn: {arguments}")
@ValueSource(ints = {10, 9, 8, 7, 6})