private void CheckUndo(string initial, string expected, string action) { // Check that the only available move is made. game = new Game(initial); game.Diagnostics = true; int checkPoint = game.Tableau.CheckPoint; if (action == "Move") { Assert.True(game.MakeMove()); } else if (action == "Deal") { game.Tableau.Deal(); } else { throw new Exception("unknown action: " + action); } string actual = TrimAll(game.ToAsciiString()); CheckResults(initial, expected, actual); game.Tableau.Revert(checkPoint); string undone = TrimAll(game.ToAsciiString()); CheckResults(initial, initial, undone); }
private void CheckSearchSucceeds(string data1, string data2) { string initial = data1; game = new Game(initial, AlgorithmType.Search); game.Diagnostics = true; Assert.True(game.MakeMove()); string expected = new Game(data2).ToAsciiString(); string actual = game.ToAsciiString(); if (expected != actual) { Print(new Game(initial)); PrintSearch(); Game.PrintSideBySide(new Game(expected), game); Utils.WriteLine("expected: {0}", expected); Utils.WriteLine("actual: {0}", actual); } Assert.Equal(expected, actual); }
private void CheckMoveFails(string initial) { // Check that the move is not made // or that a last resort move was made. game = new Game(initial); int before = game.Tableau.NumberOfSpaces; bool moved = game.MakeMove(); if (moved) { int after = game.Tableau.NumberOfSpaces; if (!(after < before)) { Print(new Game(initial)); PrintCandidates(); Print(); } Assert.True(after < before); } else { string actual = TrimAll(game.ToAsciiString()); CheckResults(initial, initial, actual); } }
private void CheckMoveSucceeds(string initial, string expected) { // Check that the only available move is made. game = new Game(initial); game.Diagnostics = true; Assert.True(game.MakeMove()); string actual = TrimAll(game.ToAsciiString()); CheckResults(initial, expected, actual); }
public void SerializationTest() { string data1 = @" @2||KhTh3s5h9s-Ah-5hKsAs7sKs-Jh-7sKs8s8h-9hJh--6s3hQh-7s9s8h Jh-9s3hJh4s|7h6h5h4h3h2hAh-2s-7h6s5s4s-KhQsJsTs9s-2sAs-Th-Js Ts-2h-Kh-2s|9hTsAs9h3sQsJs5sTh4s8s3sQh9h8h2s5hQsAhTh3s4s5s2h 8sAh7h6h6s4h4h8hQh5sQsTsAs7sKh2h6hKs8s4hQhJs6s3h6h7h@ "; Game game1 = new Game(data1); Game game2 = new Game(game1.ToAsciiString()); string data2 = game2.ToAsciiString(); Assert.Equal(TrimAll(data2), TrimAll(data1)); }