mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 16:01:42 +00:00
Add immutable quality behavior
Quality does not change. Ever
This commit is contained in:
parent
a7ff7f32cd
commit
fe94e8b8f7
@ -0,0 +1,16 @@
|
||||
package com.gildedrose.behavior.quality;
|
||||
|
||||
import com.gildedrose.Item;
|
||||
|
||||
public class ImmutableQualityBehavior implements QualityBehavior {
|
||||
|
||||
public static ImmutableQualityBehavior newInstance() {
|
||||
return new ImmutableQualityBehavior();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processQualityUpdate(Item item) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package com.gildedrose.behavior.quality;
|
||||
|
||||
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 ImmutableQualityBehaviorTest {
|
||||
|
||||
private QualityBehavior qualityBehavior;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
qualityBehavior = new ImmutableQualityBehavior();
|
||||
}
|
||||
|
||||
@Test
|
||||
void immutableQuality() {
|
||||
Item item = getItem(10);
|
||||
qualityBehavior.processQualityUpdate(item);
|
||||
|
||||
assertEquals(10, item.quality);
|
||||
}
|
||||
|
||||
@Test
|
||||
void immutableQualityZero() {
|
||||
Item item = getItem(0);
|
||||
qualityBehavior.processQualityUpdate(item);
|
||||
|
||||
assertEquals(0, item.quality);
|
||||
}
|
||||
|
||||
@Test
|
||||
void immutableQualityNegative() {
|
||||
Item item = getItem(-10);
|
||||
qualityBehavior.processQualityUpdate(item);
|
||||
|
||||
assertEquals(-10, item.quality);
|
||||
}
|
||||
|
||||
private Item getItem(int quality) {
|
||||
return new Item("SomeItem", 0, quality);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user