Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo 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));
        }