diff --git a/Praktikum/VINF_TicTacToe/test/tictactoePraktikum/MockUpClass.java b/Praktikum/VINF_TicTacToe/test/tictactoePraktikum/MockUpClass.java new file mode 100644 index 0000000000000000000000000000000000000000..817835a5e6b76f4a9713e60070d96c947fead245 --- /dev/null +++ b/Praktikum/VINF_TicTacToe/test/tictactoePraktikum/MockUpClass.java @@ -0,0 +1,9 @@ +package tictactoePraktikum; + +public class MockUpClass implements TicTacToeUI{ + + @Override + public String getZugeingabe(char[][] spielbrett, char aktuellerSpieler) { + return null; + } +} diff --git a/Praktikum/VINF_TicTacToe/test/tictactoePraktikum/TicTacToeTest.java b/Praktikum/VINF_TicTacToe/test/tictactoePraktikum/TicTacToeTest.java index c50cfab4b5726d307388181c082a5d2b72a13b80..95d14c9d5c583f8563603bb9c02d4823e0410933 100644 --- a/Praktikum/VINF_TicTacToe/test/tictactoePraktikum/TicTacToeTest.java +++ b/Praktikum/VINF_TicTacToe/test/tictactoePraktikum/TicTacToeTest.java @@ -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"); } }