mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 16:01:42 +00:00
Add immutable sellIn behavior
SellIn does not change. Ever.
This commit is contained in:
parent
fe94e8b8f7
commit
620d48221b
@ -0,0 +1,15 @@
|
||||
package com.gildedrose.behavior.sellin;
|
||||
|
||||
import com.gildedrose.Item;
|
||||
|
||||
public class ImmutableSellInBehavior implements SellInBehavior {
|
||||
|
||||
public static ImmutableSellInBehavior newInstance() {
|
||||
return new ImmutableSellInBehavior();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSellInUpdate(Item item) {
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package com.gildedrose.behavior.sellin;
|
||||
|
||||
import com.gildedrose.Item;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class ImmutableSellInBehaviorTest {
|
||||
|
||||
private SellInBehavior sellInBehavior;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
sellInBehavior = new ImmutableSellInBehavior();
|
||||
}
|
||||
|
||||
@Test
|
||||
void immutableSellIn() {
|
||||
Item item = getItem(10);
|
||||
sellInBehavior.processSellInUpdate(item);
|
||||
|
||||
assertEquals(10, item.sellIn);
|
||||
}
|
||||
|
||||
@Test
|
||||
void immutableSellInZero() {
|
||||
Item item = getItem(0);
|
||||
sellInBehavior.processSellInUpdate(item);
|
||||
|
||||
assertEquals(0, item.sellIn);
|
||||
}
|
||||
|
||||
@Test
|
||||
void immutableNegativeSellIn() {
|
||||
Item item = getItem(-1);
|
||||
sellInBehavior.processSellInUpdate(item);
|
||||
|
||||
assertEquals(-1, item.sellIn);
|
||||
}
|
||||
|
||||
private Item getItem(int sellIn) {
|
||||
return new Item("SomeItem", sellIn, 0);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user