Пример #1
0
        private MatrixAlgorithm CreateMatrixInstance()
        {
            MatrixAlgorithm matrixAlgorithm = new MatrixAlgorithm();

            matrixAlgorithm.InitializeBoard(3);
            return(matrixAlgorithm);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }