public void MakeMoveShouldReturnNull()
 {
     BoardManager board = new BoardManager();
     HumanPlayer playerOne = new HumanPlayer();
     Tuple<int,int> actual = playerOne.MakeMove(board.boardArray);
     Tuple<int,int> expected = null;
     Assert.AreEqual(expected, actual);
 }
예제 #2
0
        public void AddPlayerShouldNotOverwritePlayers()
        {
            Game target = new Game();
            target.AddPlayer(new HumanPlayer('X'));
            target.AddPlayer(new HumanPlayer('O'));

            Player actual = target.xPlayer;
            Player expected = new HumanPlayer('X');

            Assert.AreEqual(expected, actual);
        }
        public void ComputerAIConstructorTest()
        {
            BoardManager board = new BoardManager();
            HumanPlayer playerOne = new HumanPlayer();
            ComputerPlayer playerTwo = new ComputerPlayer('O');
            board.LogMove(playerOne.MakeMove(0, 0));

            ComputerAI target = new ComputerAI(playerOne.identity, playerTwo.identity);

            Assert.AreEqual('X', target.enemyIdentity);
        }
 public void GetRandomMoveShouldReturnARandomMoveFromAvailableSpaces()
 {
     BoardManager board = new BoardManager();
     HumanPlayer playerOne = new HumanPlayer();
     ComputerPlayer playerTwo = new ComputerPlayer('O');
     board.LogMove(playerOne.MakeMove(1, 1));
     ComputerAI target = new ComputerAI(playerOne.identity, playerTwo.identity);
     CreatedMove actual = target.GetRandomMove(board.boardArray);
     CreatedMove notExpected = new CreatedMove(1, 1, 'O');
     Assert.IsTrue(actual.xAxis >= 0 && actual.xAxis <= 2);
     Assert.IsTrue(actual.yAxis >= 0 && actual.yAxis <= 2);
     Assert.AreNotEqual(notExpected, actual);
 }
 public void PresentationManagerShouldBeAbleToPrintTheBoard()
 {
     PresentationManager target = new PresentationManager();
     HumanPlayer playerOne = new HumanPlayer('X');
     HumanPlayer playerTwo = new HumanPlayer('O');
     Game game = new Game(playerOne, playerTwo, new BoardManager());
     target.PrintBoard(game.board.boardArray);
     game.board.LogMove(new Tuple<int, int>(1, 1));
     target.PrintBoard(game.board.boardArray);
     game.board.LogMove(new Tuple<int, int>(0, 0));
     target.PrintBoard(game.board.boardArray);
     game.board.LogMove(new Tuple<int, int>(2, 1));
     target.PrintBoard(game.board.boardArray);
     game.board.LogMove(new Tuple<int, int>(1, 2));
     target.PrintBoard(game.board.boardArray);
 }
        public void BoardManagerShouldKnowIfThereIsATie()
        {
            BoardManager board = new BoardManager();
            HumanPlayer playerOne = new HumanPlayer('X');
            ComputerPlayer playerTwo = new ComputerPlayer('O');

            board.LogMove(new Tuple<int, int>(1, 1));
            board.LogMove(new Tuple<int, int>(0, 0));
            board.LogMove(new Tuple<int, int>(0, 1));
            board.LogMove(new Tuple<int, int>(2, 1));
            board.LogMove(new Tuple<int, int>(0, 2));
            board.LogMove(new Tuple<int, int>(2, 0));
            board.LogMove(new Tuple<int, int>(1, 0));
            board.LogMove(new Tuple<int, int>(1, 2));
            board.LogMove(new Tuple<int, int>(2, 2));

            Assert.AreEqual(true, board.CheckForTie());
        }
        public void BoardManagerShouldKnowIfThereIsATie()
        {
            BoardChecker target = new BoardChecker();
            BoardManager board = new BoardManager();
            HumanPlayer playerOne = new HumanPlayer('X');
            ComputerPlayer playerTwo = new ComputerPlayer('O');

            board.LogMove(playerOne.MakeMove(1, 1));
            board.LogMove(playerTwo.MakeMove(0, 0));
            board.LogMove(playerOne.MakeMove(0, 1));
            board.LogMove(playerTwo.MakeMove(2, 1));
            board.LogMove(playerOne.MakeMove(0, 2));
            board.LogMove(playerTwo.MakeMove(2, 0));
            board.LogMove(playerOne.MakeMove(1, 0));
            board.LogMove(playerTwo.MakeMove(1, 2));
            board.LogMove(playerOne.MakeMove(2, 2));

            Assert.AreEqual(true, target.CheckForTie(board.boardArray));
        }
예제 #8
0
        public void ShouldBeAbleToAddPlayers()
        {
            Game target = new Game();
            target.AddPlayer(new HumanPlayer('X'));

            Player actual = target.xPlayer;
            Player expected = new HumanPlayer('X');

            Assert.AreEqual(expected, actual);
        }
 public void ShouldBeAbleToCreatePlayersForO()
 {
     HumanPlayer playerOne = new HumanPlayer('O');
     Assert.AreEqual(playerOne.identity, 'O');
 }
 public void ConstructorShouldDefaultToX()
 {
     HumanPlayer playerOne = new HumanPlayer();
     Assert.AreEqual(playerOne.identity, 'X');
 }
        public void CheckForWinShouldReturnTrueIfThereAreThreeOsInARow()
        {
            BoardChecker target = new BoardChecker();

            //Three Across the Top
            BoardManager board = new BoardManager();
            HumanPlayer playerOne = new HumanPlayer('o');
            board.LogMove(playerOne.MakeMove(0, 0));
            board.LogMove(playerOne.MakeMove(1, 0));
            board.LogMove(playerOne.MakeMove(2, 0));
            Assert.AreEqual(true, target.CheckForWin(board.boardArray));

            //Three Across the Middle
            board = new BoardManager();
            board.LogMove(playerOne.MakeMove(0, 1));
            board.LogMove(playerOne.MakeMove(1, 1));
            board.LogMove(playerOne.MakeMove(2, 1));
            Assert.AreEqual(true, target.CheckForWin(board.boardArray));

            //Three Across the Bottom
            board = new BoardManager();
            board.LogMove(playerOne.MakeMove(0, 2));
            board.LogMove(playerOne.MakeMove(1, 2));
            board.LogMove(playerOne.MakeMove(2, 2));
            Assert.AreEqual(true, target.CheckForWin(board.boardArray));

            //Three Down the Left Side
            board = new BoardManager();
            board.LogMove(playerOne.MakeMove(0, 0));
            board.LogMove(playerOne.MakeMove(0, 1));
            board.LogMove(playerOne.MakeMove(0, 2));
            Assert.AreEqual(true, target.CheckForWin(board.boardArray));

            //Three Down the Middle
            board = new BoardManager();
            board.LogMove(playerOne.MakeMove(1, 0));
            board.LogMove(playerOne.MakeMove(1, 1));
            board.LogMove(playerOne.MakeMove(1, 2));
            Assert.AreEqual(true, target.CheckForWin(board.boardArray));

            //Three Down the Right Side
            board = new BoardManager();
            board.LogMove(playerOne.MakeMove(1, 0));
            board.LogMove(playerOne.MakeMove(1, 1));
            board.LogMove(playerOne.MakeMove(1, 2));
            Assert.AreEqual(true, target.CheckForWin(board.boardArray));

            //Three In A Slash
            board = new BoardManager();
            board.LogMove(playerOne.MakeMove(0, 2));
            board.LogMove(playerOne.MakeMove(1, 1));
            board.LogMove(playerOne.MakeMove(2, 0));
            Assert.AreEqual(true, target.CheckForWin(board.boardArray));

            //Three In A Backslash
            board = new BoardManager();
            board.LogMove(playerOne.MakeMove(0, 0));
            board.LogMove(playerOne.MakeMove(1, 1));
            board.LogMove(playerOne.MakeMove(2, 2));
            Assert.AreEqual(true, target.CheckForWin(board.boardArray));
        }