private MatrixAlgorithm CreateMatrixInstance() { MatrixAlgorithm matrixAlgorithm = new MatrixAlgorithm(); matrixAlgorithm.InitializeBoard(3); return(matrixAlgorithm); }
public void GetMovesLeft_TicTaxToeMatrixBoardIsEqualToPlayerTypeUnassigned_ReturnFalse() { MatrixAlgorithm matrixAlgorithm = this.CreateMatrixInstance(); matrixAlgorithm.Board[0, 0] = PlayerType.Unassigned; Boolean actual = this.CreateInstance().GetMovesLeft(matrixAlgorithm); Assert.That(() => actual, Is.False); }
public void GetMovesLeft_TicTaxToeMatrixBoardIsNotEqualToPlayerTypeUnassigned_ReturnTrue() { MatrixAlgorithm matrixAlgorithm = this.CreateMatrixInstance(); for (Int32 x = 0; x < 3; x++) { for (Int32 y = 0; y < 3; y++) { matrixAlgorithm.Board[x, y] = PlayerType.X; } } Boolean actual = this.CreateInstance().GetMovesLeft(matrixAlgorithm); Assert.That(() => actual, Is.True); }
public void CheckWinner_PlayerWinsWithDiagonalsFromLeftToRight_ReturnTrue() { PointIndex test = new PointIndex { X = 0, Y = 0 }; MatrixAlgorithm matrixAlgorithm = this.CreateInstance(); matrixAlgorithm.Board = new PlayerType[3, 3] { { PlayerType.X, PlayerType.Unassigned, PlayerType.Unassigned }, { PlayerType.Unassigned, PlayerType.X, PlayerType.Unassigned }, { PlayerType.Unassigned, PlayerType.Unassigned, PlayerType.X } }; Assert.That(() => matrixAlgorithm.CheckWinner(test, PlayerType.X), Is.True); }
public void CheckWinner_NoWinner_ReturnFalse() { PointIndex test = new PointIndex { X = 0, Y = 0 }; MatrixAlgorithm matrixAlgorithm = this.CreateInstance(); matrixAlgorithm.Board = new PlayerType[3, 3] { { PlayerType.X, PlayerType.O, PlayerType.X }, { PlayerType.X, PlayerType.O, PlayerType.X }, { PlayerType.O, PlayerType.X, PlayerType.O } }; Assert.That(() => matrixAlgorithm.CheckWinner(test, PlayerType.Unassigned), Is.False); }
public void CheckWinner_GameEndsWithDraw_ReturnTrue() { PointIndex test = new PointIndex { X = 0, Y = 0 }; MatrixAlgorithm matrixAlgorithm = this.CreateInstance(); matrixAlgorithm.Board = new PlayerType[3, 3] { { PlayerType.X, PlayerType.X, PlayerType.O }, { PlayerType.O, PlayerType.O, PlayerType.X }, { PlayerType.X, PlayerType.O, PlayerType.X } }; matrixAlgorithm.CurrentTurnCount = 8; Assert.That(() => matrixAlgorithm.CheckWinner(test, PlayerType.X), Is.True); }