GildedRose-Refactoring-Kata/Java/src/test/java/com/gildedrose/GRItemValidateItemTest.java
Ben Leers 3a0735e237 Add Tests for current code base
add GRItem
add validation for initial quality values + tests
2020-06-29 09:42:08 +02:00

33 lines
974 B
Java

package com.gildedrose;
import org.junit.jupiter.api.Test;
import static org.apache.commons.lang3.RandomStringUtils.random;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
class GRItemValidateItemTest {
private static final String SULFURAS = "Sulfuras, Hand of Ragnaros";
@Test
public void throwsExceptionWhenItemValueIsNegative() {
Item item = new Item(random(5), 10, -1);
assertThatThrownBy(() -> GRItem.validateItem(item)).isInstanceOf(ItemQualityIsNegativeException.class);
}
@Test
public void throwsExceptionWhenItemValueExceedsMaxValue() {
Item item = new Item(random(5), 10, 51);
assertThatThrownBy(() -> GRItem.validateItem(item)).isInstanceOf(ItemQualityExceedsMaxValueException.class);
}
@Test
public void doesNotThrowExceptionWhenItemValueExceedsMaxValueAndItemIsSulfuras() {
Item item = new Item(SULFURAS, 10, 51);
GRItem.validateItem(item);
}
}