mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 06:21:29 +00:00
The Quality of an item is never negative
This commit is contained in:
parent
d278d9b389
commit
172ba212f6
@ -11,7 +11,7 @@
|
|||||||
# unit tests
|
# unit tests
|
||||||
-[x] At the end of each day our system lowers both values for every item
|
-[x] At the end of each day our system lowers both values for every item
|
||||||
-[x] Once the sell by date has passed, Quality degrades twice as fast
|
-[x] Once the sell by date has passed, Quality degrades twice as fast
|
||||||
-[ ] The Quality of an item is never negative
|
-[x] The Quality of an item is never negative
|
||||||
-[ ] "Aged Brie" actually increases in Quality the older it gets
|
-[ ] "Aged Brie" actually increases in Quality the older it gets
|
||||||
-[ ] The Quality of an item is never more than 50
|
-[ ] The Quality of an item is never more than 50
|
||||||
-[ ] "Sulfuras", being a legendary item, never has to be sold or decreases in Quality
|
-[ ] "Sulfuras", being a legendary item, never has to be sold or decreases in Quality
|
||||||
|
|||||||
17
Java/pom.xml
17
Java/pom.xml
@ -11,13 +11,15 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
<junit-jupiter.version>5.5.2</junit-jupiter.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
<version>4.12</version>
|
<version>${junit-jupiter.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@ -31,6 +33,15 @@
|
|||||||
<target>${java.version}</target>
|
<target>${java.version}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Need at least 2.22.0 to support JUnit 5 -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>3.0.0-M3</version>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
package com.gildedrose;
|
package com.gildedrose;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class GildedRoseTest {
|
public class GildedRoseTest {
|
||||||
|
|
||||||
@ -14,8 +15,8 @@ public class GildedRoseTest {
|
|||||||
assertEquals("foo", app.items[0].name);
|
assertEquals("foo", app.items[0].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//At the end of each day our system lowers both values for every item
|
|
||||||
@Test
|
@Test
|
||||||
|
@DisplayName("At the end of each day our system lowers both values for every item")
|
||||||
public void shouldLowerBothValues(){
|
public void shouldLowerBothValues(){
|
||||||
Item[] items = new Item[] { TestHelper.getItem("foobar", 2, 2) };
|
Item[] items = new Item[] { TestHelper.getItem("foobar", 2, 2) };
|
||||||
GildedRose app = new GildedRose(items);
|
GildedRose app = new GildedRose(items);
|
||||||
@ -24,8 +25,8 @@ public class GildedRoseTest {
|
|||||||
assertEquals(1, app.items[0].sellIn);
|
assertEquals(1, app.items[0].sellIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Once the sell by date has passed (<=0), Quality degrades twice as fast
|
|
||||||
@Test
|
@Test
|
||||||
|
@DisplayName("Once the sell by date has passed (<=0), Quality degrades twice as fast")
|
||||||
public void shouldDowngradeTwiceAsFastAfterSellDate(){
|
public void shouldDowngradeTwiceAsFastAfterSellDate(){
|
||||||
Item[] items = new Item[] { TestHelper.getItem("foobar", 1, 5) };
|
Item[] items = new Item[] { TestHelper.getItem("foobar", 1, 5) };
|
||||||
GildedRose app = new GildedRose(items);
|
GildedRose app = new GildedRose(items);
|
||||||
@ -41,4 +42,19 @@ public class GildedRoseTest {
|
|||||||
assertEquals(-1, app.items[0].sellIn);
|
assertEquals(-1, app.items[0].sellIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("The Quality of an item is never negative")
|
||||||
|
public void shouldNeverHaveANegativeQuality() {
|
||||||
|
Item[] items = new Item[]{TestHelper.getItem("foobar", 0, 0)};
|
||||||
|
GildedRose app = new GildedRose(items);
|
||||||
|
|
||||||
|
//day 1, drop by 1
|
||||||
|
app.updateQuality();
|
||||||
|
assertEquals(0, app.items[0].quality);
|
||||||
|
|
||||||
|
//day 2, drop by 1 => quality is still 0
|
||||||
|
app.updateQuality();
|
||||||
|
assertEquals(0, app.items[0].quality);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user