mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 23:11:28 +00:00
33 lines
974 B
Java
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);
|
|
}
|
|
} |