diff --git a/Mzinga.Test/GameBoardTests.cs b/Mzinga.Test/GameBoardTests.cs index bed23bd8..84a65c9b 100644 --- a/Mzinga.Test/GameBoardTests.cs +++ b/Mzinga.Test/GameBoardTests.cs @@ -145,9 +145,57 @@ public void GameBoard_CanCommitSuicideTest() } [TestMethod] - public void GameBoard_InvalidMovesTest() + public void GameBoard_ValidMovesForQueenBeeTest() { - TestUtils.LoadAndExecuteTestCases("GameBoard_InvalidMovesTest.csv"); + TestUtils.LoadAndExecuteTestCases("GameBoard_ValidMovesForQueenBeeTest.csv"); + } + + [TestMethod] + public void GameBoard_ValidMovesForSpiderTest() + { + TestUtils.LoadAndExecuteTestCases("GameBoard_ValidMovesForSpiderTest.csv"); + } + + [TestMethod] + public void GameBoard_ValidMovesForBeetleTest() + { + TestUtils.LoadAndExecuteTestCases("GameBoard_ValidMovesForBeetleTest.csv"); + } + + [TestMethod] + public void GameBoard_ValidMovesForGrasshopperTest() + { + TestUtils.LoadAndExecuteTestCases("GameBoard_ValidMovesForGrasshopperTest.csv"); + } + + [TestMethod] + public void GameBoard_ValidMovesForSoldierAntTest() + { + TestUtils.LoadAndExecuteTestCases("GameBoard_ValidMovesForSoldierAntTest.csv"); + } + + [TestMethod] + public void GameBoard_ValidMovesForMosquitoTest() + { + TestUtils.LoadAndExecuteTestCases("GameBoard_ValidMovesForMosquitoTest.csv"); + } + + [TestMethod] + public void GameBoard_ValidMovesForLadybugTest() + { + TestUtils.LoadAndExecuteTestCases("GameBoard_ValidMovesForLadybugTest.csv"); + } + + [TestMethod] + public void GameBoard_ValidMovesForPillbugTest() + { + TestUtils.LoadAndExecuteTestCases("GameBoard_ValidMovesForPillbugTest.csv"); + } + + [TestMethod] + public void GameBoard_InvalidMovesByRuleTest() + { + TestUtils.LoadAndExecuteTestCases("GameBoard_InvalidMovesByRuleTest.csv"); } [TestMethod] @@ -191,6 +239,47 @@ private static Direction[] StraightLine(Direction direction, int length) return line; } + private class GameBoardValidMoveTestCase : ITestCase + { + public GameBoard Board; + + public string[] ValidMoveStrings; + public Move[] ValidMoves; + + public void Execute() + { + Trace.TraceInformation($"Current Board: {Board.ToGameString()}"); + for (int i = 0; i < ValidMoveStrings.Length; i++) + { + Trace.TraceInformation($"Playing: {ValidMoveStrings[i]}"); + Board.Play(ValidMoves[i]); + Board.UndoLastMove(); + } + } + + public void Parse(string s) + { + if (string.IsNullOrWhiteSpace(s)) + { + throw new ArgumentNullException(nameof(s)); + } + + s = s.Trim(); + + string[] vals = s.Split('\t'); + + Board = GameBoard.ParseGameString(vals[0]); + + ValidMoveStrings = vals[1].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); + ValidMoves = new Move[ValidMoveStrings.Length]; + + for (int i = 0; i < ValidMoveStrings.Length; i++) + { + ValidMoves[i] = NotationUtils.ParseMoveString(Board, ValidMoveStrings[i]); + } + } + } + private class GameBoardInvalidMoveTestCase : ITestCase { public GameBoard Board; diff --git a/Mzinga.Test/Mzinga.Test.csproj b/Mzinga.Test/Mzinga.Test.csproj index 909f52f9..d775d597 100644 --- a/Mzinga.Test/Mzinga.Test.csproj +++ b/Mzinga.Test/Mzinga.Test.csproj @@ -98,7 +98,31 @@ PreserveNewest - + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + PreserveNewest diff --git a/Mzinga.Test/TestCases/GameBoardTests/GameBoard_InvalidMovesTest.csv b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_InvalidMovesByRuleTest.csv similarity index 100% rename from Mzinga.Test/TestCases/GameBoardTests/GameBoard_InvalidMovesTest.csv rename to Mzinga.Test/TestCases/GameBoardTests/GameBoard_InvalidMovesByRuleTest.csv diff --git a/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForBeetleTest.csv b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForBeetleTest.csv new file mode 100644 index 00000000..7a468c5e --- /dev/null +++ b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForBeetleTest.csv @@ -0,0 +1,2 @@ +# Valid Placements +Base;InProgress;White[2];wS1;bS1 wS1- wB1 \wS1;wB1 /wS1;wB1 -wS1 \ No newline at end of file diff --git a/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForGrasshopperTest.csv b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForGrasshopperTest.csv new file mode 100644 index 00000000..b3d24336 --- /dev/null +++ b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForGrasshopperTest.csv @@ -0,0 +1,2 @@ +# Valid Placements +Base;InProgress;White[2];wS1;bS1 wS1- wG1 \wS1;wG1 /wS1;wG1 -wS1 \ No newline at end of file diff --git a/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForLadybugTest.csv b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForLadybugTest.csv new file mode 100644 index 00000000..e7906e84 --- /dev/null +++ b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForLadybugTest.csv @@ -0,0 +1,2 @@ +# Valid Placements +Base+L;InProgress;White[2];wS1;bS1 wS1- wL \wS1;wL /wS1;wL -wS1 \ No newline at end of file diff --git a/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForMosquitoTest.csv b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForMosquitoTest.csv new file mode 100644 index 00000000..4efe25c6 --- /dev/null +++ b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForMosquitoTest.csv @@ -0,0 +1,2 @@ +# Valid Placements +Base+M;InProgress;White[2];wS1;bS1 wS1- wM \wS1;wM /wS1;wM -wS1 \ No newline at end of file diff --git a/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForPillbugTest.csv b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForPillbugTest.csv new file mode 100644 index 00000000..5076bd1b --- /dev/null +++ b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForPillbugTest.csv @@ -0,0 +1,2 @@ +# Valid Placements +Base+P;InProgress;White[2];wS1;bS1 wS1- wP \wS1;wP /wS1;wP -wS1 \ No newline at end of file diff --git a/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForQueenBeeTest.csv b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForQueenBeeTest.csv new file mode 100644 index 00000000..4f0187dd --- /dev/null +++ b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForQueenBeeTest.csv @@ -0,0 +1,2 @@ +# Valid Placements +Base;InProgress;White[2];wS1;bS1 wS1- wQ \wS1;wQ /wS1;wQ -wS1 \ No newline at end of file diff --git a/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForSoldierAntTest.csv b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForSoldierAntTest.csv new file mode 100644 index 00000000..6bae8a92 --- /dev/null +++ b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForSoldierAntTest.csv @@ -0,0 +1,2 @@ +# Valid Placements +Base;InProgress;White[2];wS1;bS1 wS1- wA1 \wS1;wA1 /wS1;wA1 -wS1 \ No newline at end of file diff --git a/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForSpiderTest.csv b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForSpiderTest.csv new file mode 100644 index 00000000..8973b6b7 --- /dev/null +++ b/Mzinga.Test/TestCases/GameBoardTests/GameBoard_ValidMovesForSpiderTest.csv @@ -0,0 +1,2 @@ +# Valid Placements +Base;InProgress;White[2];wS1;bS1 wS1- wS2 \wS1;wS2 /wS1;wS2 -wS1 \ No newline at end of file