Esempio n. 1
0
        public void PlayerUnbeatablePlaysFirstAndMarksCenter()
        {
            Board board = CreateBoard();

            PlayerUnbeatable playerUnbeatable = CreatePlayerUnbeatable();

            board.MarkBoard(playerUnbeatable.Play(board));

            Assert.AreEqual(playerUnbeatable.Marker, board.GetMarkAtPosition(1, 1));
        }
Esempio n. 2
0
        public void PlayerUnbeatablePlaysSecondWithCenterEmptyAndMarksCenter()
        {
            Board board = CreateBoard();

            const Marker marker = Marker.X;

            board.MarkBoard(CreatePlay(1, 0, marker));

            PlayerUnbeatable playerUnbeatable = CreatePlayerUnbeatable();

            board.MarkBoard(playerUnbeatable.Play(board));

            Assert.AreEqual(playerUnbeatable.Marker, board.GetMarkAtPosition(1, 1));
        }
Esempio n. 3
0
        public void WinInDiagonalUpToDownRightToLeft()
        {
            Board board = CreateBoard();

            const Marker marker = Marker.O;

            board.MarkBoard(CreatePlay(2, 0, marker));
            board.MarkBoard(CreatePlay(1, 1, marker));

            PlayerUnbeatable playerUnbeatable = CreatePlayerUnbeatable();

            board.MarkBoard(playerUnbeatable.Play(board));

            Assert.AreEqual(playerUnbeatable.Marker, board.GetMarkAtPosition(0, 2));
        }
Esempio n. 4
0
        public void AvoidDefeatInDiagonalLineUpToDownLeftToRight()
        {
            Board board = CreateBoard();

            const Marker marker = Marker.X;

            board.MarkBoard(CreatePlay(0, 0, marker));
            board.MarkBoard(CreatePlay(1, 1, marker));

            PlayerUnbeatable playerUnbeatable = CreatePlayerUnbeatable();

            board.MarkBoard(playerUnbeatable.Play(board));

            Assert.AreEqual(playerUnbeatable.Marker, board.GetMarkAtPosition(2, 2));
        }
Esempio n. 5
0
        public void AvoidDefeatInHorizontalLine(int horizontalLine)
        {
            Board board = CreateBoard();

            const Marker marker = Marker.X;

            board.MarkBoard(CreatePlay(0, horizontalLine, marker));
            board.MarkBoard(CreatePlay(1, horizontalLine, marker));

            if (horizontalLine != 1)
            {
                board.MarkBoard(CreatePlay(1, 1, Marker.O));
            }

            PlayerUnbeatable playerUnbeatable = new PlayerUnbeatable(Marker.O);

            board.MarkBoard(playerUnbeatable.Play(board));

            Assert.AreEqual(playerUnbeatable.Marker, board.GetMarkAtPosition(2, horizontalLine));
        }
Esempio n. 6
0
        public void AvoidDefeatInVerticalLine(int verticalLine)
        {
            Board board = CreateBoard();

            const Marker marker = Marker.X;

            board.MarkBoard(CreatePlay(verticalLine, 0, marker));
            board.MarkBoard(CreatePlay(verticalLine, 1, marker));

            if (verticalLine != 1)
            {
                board.MarkBoard(CreatePlay(1, 1, Marker.O));
            }

            PlayerUnbeatable playerUnbeatable = CreatePlayerUnbeatable();

            board.MarkBoard(playerUnbeatable.Play(board));

            Assert.AreEqual(playerUnbeatable.Marker, board.GetMarkAtPosition(verticalLine, 2));
        }