public void SubgridCantClaimClaimedCellTest()
        {
            supergrid.Reset();

            supergrid.ClaimCell(0, 0, 0, 0);

            TicTacToeException ex = Assert.ThrowsException <TicTacToeException>(() =>
            {
                supergrid.ClaimCell(0, 0, 0, 0);
            });

            Assert.AreEqual("Cell is already claimed", ex.Message);
        }
        public void AssertCantPlayInWonGrid()
        {
            SubgridWinVerticalTest();

            Debug.Assert(supergrid.CheckGridStatus(0, 0) != TicTacToeGridStatus.Contested, "recheck SubgridWinVerticalTest -- subgrid 0,0 should have been won");
            Debug.Assert(supergrid.NextMoveX != -1, "recheck SubgridWinVerticalTest -- last move should not point at a won subgrid");

            //
            supergrid.ClaimCell(supergrid.NextMoveX, supergrid.NextMoveY, 0, 0);

            TicTacToePlayerTurn whoseTurnBeforeClaimCellFailure = supergrid.WhoseTurn;

            //make sure that nobody can claim any cells in the 'won' subgrid
            TicTacToeException ex = Assert.ThrowsException <TicTacToeException>(() =>
            {
                supergrid.ClaimCell(0, 0, 0, 0);
            });

            StringAssert.Contains("Grid is already filled in", ex.Message);

            //Assert that it's still X's turn -- i.e. that the exception didn't forfeit X's turn
            Assert.AreEqual(whoseTurnBeforeClaimCellFailure, supergrid.WhoseTurn);
        }
Exemplo n.º 3
0
 public static ResponseWrapper <T> GetEmptyResponseWrapperFromException <T>(TicTacToeException exception)
 {
     return(new ResponseWrapper <T> {
         StatusCode = exception.StatusCode, Message = exception.Message
     });
 }