/** * Initialize variables for the test process. * * @throws Exception possible Exception. */ @Before public void setUp() throws Exception { testWon = new Won(1); testWon.tMain = mockedGame; when(mockedGame.getGame()).thenReturn(new Game(0, 0, mockedLogger, 1)); }
public void win() { boolean allClicked = true; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { if (flag[i][j] == true && bombs[i][j] == false) { allClicked = false; } if (clicked[i][j] == false) { allClicked = false; break; } } } if (allClicked != false) { Won won = new Won(); won.setLocationRelativeTo(null); won.setVisible(true); dispose(); } }
/** * Test whether keyReleased() works correctly. Key: 3. * * @throws Exception possible Exception. */ @Test public void testKeyReleased3() throws Exception { testWon.keyReleased(Input.KEY_3, 'a'); }
/** * Test whether keyReleased() works correctly. Key: 1. * * @throws Exception possible Exception. */ @Test public void testKeyReleased1() throws Exception { testWon.keyReleased(Input.KEY_1, 'a'); verify(mockedGame).newGame(1); }
/** * Test whether getID() works correctly. * * @throws Exception possible Exception. */ @Test public void testGetID() throws Exception { assertEquals(1, testWon.getID()); }
/** * Test whether update() works correctly, and thus, does nothing. * * @throws Exception possible Exception. */ @Test public void testUpdate() throws Exception { testWon.tExit = true; testWon.update(mockedContainer, mockedGame, 0); }
/** * Test whether keyReleased() works correctly. Key: yen. * * @throws Exception possible Exception. */ @Test public void testKeyReleasedDefault() throws Exception { testWon.keyReleased(Input.KEY_YEN, 'a'); }
/** * Test whether keyReleased() works correctly. Key: space. * * @throws Exception possible Exception. */ @Test public void testKeyReleasedSpace() throws Exception { testWon.keyReleased(Input.KEY_SPACE, 'a'); verify(mockedGame).enterState(5); }