import static org.junit.Assert.*; import org.junit.*; /******************************************* * The test class for Chuck * * @author Resendiz * @version February 2021 ******************************************/ public class MyDiceGameTest { /****************************************************** * Test initial values of the constructor *****************************************************/ @Test public void testConstructor() { GameManager game = new GameManager(6); int credits = game.getDice().getCredits(); // confirm there is only one copy of Title 1 Assert.assertEquals("Game should start with 10 credits", credits, 10); } /****************************************************** * Test Large *****************************************************/ @Test public void testLarge() { // confirm large is rolled GameManager game = new GameManager(6); int credits = game.getDice().getCredits(); game.getDice().testRoll(new int[]{6, 6, 5}); game.getDice().checkLarge(); Assert.assertEquals("Dice => (6,6,5): credits should stay the same", game.getDice().getCredits(), credits); // confirm large is not rolled GameManager game2 = new GameManager(6); credits = game2.getDice().getCredits(); game2.getDice().testRoll(new int[]{1, 2, 3}); game2.getDice().checkLarge(); Assert.assertEquals("Dice => (1,2,3): credits should decrease by one", game2.getDice().getCredits(), credits - 1); // confirm large rolled with three of kind GameManager game3 = new GameManager(6); credits = game3.getDice().getCredits(); game3.getDice().testRoll(new int[]{4, 4, 4}); game3.getDice().checkLarge(); game3.getDice().checkTriplets(); Assert.assertEquals("Dice => (4,4,4): credits should increased by one", game3.getDice().getCredits(), credits + 1); // confirm large is not rolled with three of kind GameManager game4 = new GameManager(6); credits = game4.getDice().getCredits(); game4.getDice().testRoll(new int[]{3, 3, 3}); game4.getDice().checkLarge(); game4.getDice().checkTriplets(); Assert.assertEquals("Dice => (3,3,3): credits should stay the same", game4.getDice().getCredits(), credits); } /****************************************************** * Test Triplets *****************************************************/ @Test public void testTriplets() { // confirm triplets is rolled GameManager game = new GameManager(6); int credits = game.getDice().getCredits(); game.getDice().testRoll(new int[]{1, 1, 1}); game.getDice().checkTriplets(); Assert.assertEquals("Dice => (1,1,1): credits should stay the same", game.getDice().getCredits(), credits); } }