diff --git a/build.gradle b/build.gradle index 78b9d6b..b368d34 100644 --- a/build.gradle +++ b/build.gradle @@ -14,4 +14,5 @@ repositories { dependencies { testCompile 'junit:junit:4.12' + testCompile 'org.hamcrest:hamcrest-all:1.3' } diff --git a/src/test/java/com/pickominio/service/RollTest.java b/src/test/java/com/pickominio/service/RollTest.java new file mode 100644 index 0000000..0ed4232 --- /dev/null +++ b/src/test/java/com/pickominio/service/RollTest.java @@ -0,0 +1,39 @@ +package com.pickominio.service; + +import com.pickominio.model.ActiveDiceSet; +import com.pickominio.model.Dice; +import com.pickominio.model.DiceSet; +import org.junit.Before; +import org.junit.Test; + +import java.util.stream.Stream; + +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; +import static org.hamcrest.Matchers.lessThanOrEqualTo; +import static org.junit.Assert.*; + +public class RollTest { + private DiceSet diceSet; + private Roll roll; + + @Before + public void setUp() throws Exception { + diceSet = ActiveDiceSet.buildNewSet(); + roll = new Roll(); + } + + @Test + public void diceSet() { + roll.diceSet(diceSet); + int[] values = Stream.of(diceSet.toString().split(" ")) + .mapToInt(value -> Integer.parseInt(value)) + .toArray(); + for (int diceValue : values) { + assertThat( + diceValue, + allOf(greaterThanOrEqualTo(Dice.MIN_DICE_VALUE), lessThanOrEqualTo(Dice.MAX_DICE_VALUE)) + ); + } + } +} \ No newline at end of file