mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
Create Golden Master Approval Test
This commit is contained in:
parent
69618dd6bd
commit
e9864f986a
@ -11,7 +11,7 @@ class GildedRoseTest {
|
||||
Item[] items = new Item[] { new Item("foo", 0, 0) };
|
||||
GildedRose app = new GildedRose(items);
|
||||
app.updateQuality();
|
||||
assertEquals("fixme", app.items[0].name);
|
||||
assertEquals("foo", app.items[0].name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,42 @@
|
||||
package com.gildedrose;
|
||||
|
||||
import org.approvaltests.combinations.CombinationApprovals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
class GoldenMasterApprovalTest {
|
||||
|
||||
@Test
|
||||
void
|
||||
gildedRoseApprovalTest() {
|
||||
CombinationApprovals.verifyAllCombinations(
|
||||
this::updateItem,
|
||||
itemTypes(),
|
||||
qualityRangeValues(),
|
||||
sellInRangeValues()
|
||||
);
|
||||
}
|
||||
|
||||
private String[] itemTypes() {
|
||||
return new String[]{"common item", "Aged Brie", "Backstage passes to a TAFKAL80ETC concert", "Sulfuras, Hand of Ragnaros"};
|
||||
}
|
||||
|
||||
private Integer[] sellInRangeValues() {
|
||||
return IntStream.range(-1, 12).boxed().toArray(Integer[]::new);
|
||||
}
|
||||
|
||||
private Integer[] qualityRangeValues() {
|
||||
return IntStream.range(0, 51).boxed().toArray(Integer[]::new);
|
||||
}
|
||||
|
||||
private Item updateItem(String name, int quality, int sellIn) {
|
||||
final Item item = new ItemBuilder()
|
||||
.setName(name)
|
||||
.setSellIn(sellIn)
|
||||
.setQuality(quality)
|
||||
.createItem();
|
||||
new GildedRose(new Item[]{item}).updateQuality();
|
||||
return item;
|
||||
}
|
||||
}
|
||||
26
Java/src/test/java/com/gildedrose/ItemBuilder.java
Normal file
26
Java/src/test/java/com/gildedrose/ItemBuilder.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.gildedrose;
|
||||
|
||||
public class ItemBuilder {
|
||||
private String name;
|
||||
private int sellIn;
|
||||
private int quality;
|
||||
|
||||
public ItemBuilder setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setSellIn(int sellIn) {
|
||||
this.sellIn = sellIn;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setQuality(int quality) {
|
||||
this.quality = quality;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item createItem() {
|
||||
return new Item(name, sellIn, quality);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user