- Increase project information in README.md;

- Refactor the foo test into "+5 Dexterity Vest" item test;
This commit is contained in:
Luciano Minuzzi 2020-05-02 19:33:32 +02:00
parent 58cf291e65
commit b12a345e6c
2 changed files with 167 additions and 7 deletions

View File

@ -1,4 +1,4 @@
<h3>How to Run Tests:</h3>
<h3>How to Run Tests</h3>
<ul>
<li>CLI - gradlew :cleanTest :test --tests "com.gildedrose.GildedRoseTest.foo"</li>
<li>Intellij
@ -8,3 +8,153 @@
</ul>
</li>
</ul>
<h3>The System</h3>
<ul>
<li>
All items have a SellIn value which denotes the number of days we
have to sell the item.
</li>
<li>All items have a Quality value which denotes how valuable the item is.</li>
<li>At the end of each day our system lowers both values for every item.</li>
</ul>
<h3>New Requisites</h3>
<ul>
<li>Once the sell by date has passed, Quality degrades twice as fast</li>
<li>The Quality of an item is never negative</li>
<li>"Aged Brie" actually increases in Quality the older it gets</li>
<li>The Quality of an item is never more than 50</li>
<li>"Sulfuras", being a legendary item, never has to be sold or decreases in Quality</li>
<li>"Backstage passes", like aged brie, increases in Quality as its SellIn value approaches;</li>
<li>Quality increases by 2 when there are 10 days or less and by 3 when there are 5 days or less but</li>
<li>Quality drops to 0 after the concert</li>
<li>Conjured" items degrade in Quality twice as fast as normal items</li>
</ul>
<h3>Restrictions</h3>
<ul>
<li>Do not alter the Item class or Items property</li>
<li>
An item can never have its Quality increase above 50, however "Sulfuras" is a
legendary item and as such its Quality is 80 and it never alters.
</li>
</ul>
<h3>Original Output</h3>
<div>OMGHAI!</div>
<div>-------- day 0 --------</div>
<table>
<thead>
<tr>
<th>name</th>
<th>sellIn</th>
<th>quality</th>
</tr>
</thead>
<tbody>
<tr>
<td>+5 Dexterity Vest</td>
<td>10</td>
<td>20</td>
</tr>
<tr>
<td>Aged Brie</td>
<td>2</td>
<td>0</td>
</tr>
<tr>
<td>Elixir of the Mongoose</td>
<td>5</td>
<td>7</td>
</tr>
<tr>
<td>Sulfuras, Hand of Ragnaros</td>
<td>0</td>
<td>80</td>
</tr>
<tr>
<td>Sulfuras, Hand of Ragnaros</td>
<td>-1</td>
<td>80</td>
</tr>
<tr>
<td>Backstage passes to a TAFKAL80ETC concert</td>
<td>15</td>
<td>20</td>
</tr>
<tr>
<td>Backstage passes to a TAFKAL80ETC concert</td>
<td>10</td>
<td>49</td>
</tr>
<tr>
<td>Backstage passes to a TAFKAL80ETC concert</td>
<td>5</td>
<td>49</td>
</tr>
<tr>
<td>Conjured Mana Cake</td>
<td>3</td>
<td>6</td>
</tr>
</tbody>
</table>
<div>-------- day 1 --------</div>
<table>
<thead>
<tr>
<th>name</th>
<th>sellIn</th>
<th>quality</th>
</tr>
</thead>
<tbody>
<tr>
<td>+5 Dexterity Vest</td>
<td>9</td>
<td>19</td>
</tr>
<tr>
<td>Aged Brie</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>Elixir of the Mongoose</td>
<td>4</td>
<td>6</td>
</tr>
<tr>
<td>Sulfuras, Hand of Ragnaros</td>
<td>0</td>
<td>80</td>
</tr>
<tr>
<td>Sulfuras, Hand of Ragnaros</td>
<td>-1</td>
<td>80</td>
</tr>
<tr>
<td>Backstage passes to a TAFKAL80ETC concert</td>
<td>14</td>
<td>21</td>
</tr>
<tr>
<td>Backstage passes to a TAFKAL80ETC concert</td>
<td>9</td>
<td>50</td>
</tr>
<tr>
<td>Backstage passes to a TAFKAL80ETC concert</td>
<td>4</td>
<td>50</td>
</tr>
<tr>
<td>Conjured Mana Cake</td>
<td>2</td>
<td>5</td>
</tr>
</tbody>
</table>

View File

@ -2,16 +2,26 @@ package com.gildedrose;
import org.junit.jupiter.api.Test;
import java.util.stream.IntStream;
import static org.junit.jupiter.api.Assertions.assertEquals;
class GildedRoseTest {
@Test
void foo() {
Item[] items = new Item[] { new Item("foo", 0, 0) };
GildedRose app = new GildedRose(items);
app.updateQuality();
assertEquals("fixme", app.items[0].name);
}
void dexterityVestShouldDecreaseSellInAndQualityEachUpdate() {
String name = "+5 Dexterity Vest";
int sellIn = 10;
int quality = 20;
int days = 2;
Item[] items = new Item[]{new Item(name, sellIn, quality)};
GildedRose app = new GildedRose(items);
IntStream.rangeClosed(1, days).forEach(index -> {
app.updateQuality();
assertEquals(name, app.items[0].name);
assertEquals(sellIn - index, app.items[0].sellIn);
assertEquals(quality - index, app.items[0].quality);
});
}
}