Add immutable sellIn behavior

SellIn does not change. Ever.
This commit is contained in:
Bjorn Misseghers 2021-04-13 10:55:38 +02:00
parent fe94e8b8f7
commit 620d48221b
2 changed files with 60 additions and 0 deletions

View File

@ -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) {
}
}

View File

@ -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);
}
}