Created
May 11, 2010 00:25
-
-
Save jamescarr/396744 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package monopoly.game; | |
| import static org.hamcrest.CoreMatchers.allOf; | |
| import static org.hamcrest.CoreMatchers.equalTo; | |
| import static org.hamcrest.Matchers.greaterThanOrEqualTo; | |
| import static org.hamcrest.Matchers.lessThanOrEqualTo; | |
| import static org.junit.Assert.assertThat; | |
| import java.util.HashSet; | |
| import java.util.Set; | |
| import org.junit.Test; | |
| public class SingleDiceTest { | |
| private final SingleDice dice = new SingleDice(); | |
| @Test | |
| public void shouldReturnAnyNumberBetweenOneAndSix(){ | |
| assertThat(dice.roll(), allOf(lessThanOrEqualTo(6),greaterThanOrEqualTo(1))); | |
| } | |
| @Test | |
| public void shouldRollAllSixAtLeastOnce(){ | |
| Set<Integer> set = new HashSet<Integer>(); | |
| for(int i = 0; i< 1000; i++){ | |
| set.add(dice.roll()); | |
| } | |
| assertThat(set.size(), equalTo(6)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment