Skip to content
Snippets Groups Projects
Commit 0a608262 authored by l13f04751's avatar l13f04751
Browse files

implemented exercises 2, 3, 5, 6

parent c490e9f0
No related branches found
No related tags found
No related merge requests found
package tictactoePraktikum;
public class MockUpClass implements TicTacToeUI{
@Override
public String getZugeingabe(char[][] spielbrett, char aktuellerSpieler) {
return null;
}
}
......@@ -4,7 +4,7 @@ import org.junit.*;
import static org.junit.Assert.*;
/**
* @author lukas
* @author Lukas Friedrichsen
*
*/
public class TicTacToeTest {
......@@ -16,7 +16,7 @@ public class TicTacToeTest {
*/
@BeforeClass
public static void SetUpBeforeClass() throws Exception {
ttt = new TicTacToe(new TicTacToeApp());
ttt = new TicTacToe(new MockUpClass());
}
/**
......@@ -36,11 +36,91 @@ public class TicTacToeTest {
}
/**
* Test method for {@link briefmarkenautomat.Sendungstyp#typ(double, int)}.
* Test method for {@link tictactoePraktikum.TicTacToe#getNaechstenSpieler(int)}.
*/
@Test
public final void testTyp() {
public void testGetNaechstenSpieler() {
assertEquals(1, ttt.getNaechstenSpieler(0));
assertEquals(2, ttt.getNaechstenSpieler(1));
assertEquals(1, ttt.getNaechstenSpieler(42));
}
/**
* Test method for {@link tictactoePraktikum.TicTacToe#isGueltig(int, int)}.
*/
@Test
public void testIsGueltig() {
char[][] spielbrett = {{' ','X','O'},{'O',' ',' '},{'X',' ',' '}};
ttt.setSpielbrett(spielbrett);
assertFalse(ttt.isGueltig(-1, 0));
assertFalse(ttt.isGueltig(0, -1));
assertTrue(ttt.isGueltig(0, 0));
assertFalse(ttt.isGueltig(0, 1));
assertFalse(ttt.isGueltig(0, 2));
assertFalse(ttt.isGueltig(0, 3));
assertFalse(ttt.isGueltig(3, 0));
}
/**
* Test method for {@link tictactoePraktikum.TicTacToe#isUnentschieden()}.
*/
@Test
public void testIsUnentschieden() {
fail("Not yet implemented");
}
/**
* Test method for {@link tictactoePraktikum.TicTacToe#getSpielzustand()}.
*/
@Test
public void testGetSpielzustand() {
fail("Not yet implemented");
}
/**
* Test method for {@link tictactoePraktikum.TicTacToe#spielzug(int)}.
*/
@Test (expected=IndexOutOfBoundsException.class)
public void testSpielzug() {
ttt.spielzug(3);
}
/**
* Test method for {@link tictactoePraktikum.TicTacToe#spiel(int)}.
*/
@Test
public void testSpiel() {
fail("Not yet implemented");
}
/**
* Test method for {@link tictactoePraktikum.TicTacToe#getGewinner()}.
*/
@Test
public void testGetGewinner() {
assertEquals(' ', ttt.getGewinner());
char[][] spielbrettX = {{'X','X','X'},{' ',' ',' '},{' ',' ',' '}};
ttt.setSpielbrett(spielbrettX);
assertEquals('X', ttt.getGewinner());
char[][] spielbrettO = {{'O','O','O'},{' ',' ',' '},{' ',' ',' '}};
ttt.setSpielbrett(spielbrettO);
assertEquals('O', ttt.getGewinner());
}
/**
* Test method for {@link tictactoePraktikum.TicTacToe#getSpielbrett()}.
*/
@Test
public void testGetSpielbrett() {
fail("Not yet implemented");
}
/**
* Test method for {@link tictactoePraktikum.TicTacToe#setSpielbrett(char[][])}.
*/
@Test
public void testSetSpielbrett() {
fail("Not yet implemented");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment