Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 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);
     }
 }
Exemplo n.º 5
0
 public void EmptyTest2()
 {
     // No useful move: we lose.
     string data = "@2|||As|@";
     game = new Game(data);
     Assert.False(game.MakeMove());
     Assert.False(game.Won);
 }
Exemplo n.º 6
0
 public void EmptyTest1()
 {
     // No cards: we win.
     string data = "@2|As|||@";
     game = new Game(data);
     Assert.True(game.MakeMove());
     Assert.True(game.Won);
 }