mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-19 08:21:37 +00:00
Add test for DefaultQualityBehavior
This commit is contained in:
parent
84f07913b6
commit
45ef8fc2ad
@ -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 DefaultQualityBehaviorTest {
|
||||
|
||||
private QualityBehavior qualityBehavior;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
qualityBehavior = new DefaultQualityBehavior();
|
||||
}
|
||||
|
||||
@Test
|
||||
void decreaseQuality() {
|
||||
Item item = getItem(10);
|
||||
qualityBehavior.processQualityUpdate(item);
|
||||
|
||||
assertEquals(9, item.quality);
|
||||
}
|
||||
|
||||
@Test
|
||||
void decreaseNegativeQuality() {
|
||||
Item item = getItem(-10);
|
||||
qualityBehavior.processQualityUpdate(item);
|
||||
|
||||
assertEquals(0, item.quality);
|
||||
}
|
||||
|
||||
@Test
|
||||
void decreaseQualityZero() {
|
||||
Item item = getItem(0);
|
||||
qualityBehavior.processQualityUpdate(item);
|
||||
|
||||
assertEquals(0, item.quality);
|
||||
}
|
||||
|
||||
private Item getItem(int quality) {
|
||||
return new Item("SomeItem", 0, quality);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user