public void GameManagerShouldBeAbleToMakeAGame()
 {
     GameManager target = new GameManager();
     Game actual = target.MakeGame();
     Game expected = new Game();
     AreTwoGamesEqual(actual, expected);
 }
Ejemplo n.º 2
0
 public void GameShouldBeAbleToCheckAMovesValidity()
 {
     Game target = new Game(new HumanPlayer('X'), new HumanPlayer('O'), new BoardManager());
     target.LogMove(new Tuple<int, int>(1, 1));
     bool actual = target.IsMoveValid(new Tuple<int,int>(1,1));
     bool expected = false;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public void AddPlayerWontInputMoreThanTwoPlayers()
        {
            Game target = new Game();
            target.AddPlayer(new HumanPlayer('X'));
            target.AddPlayer(new HumanPlayer('O'));
            target.AddPlayer(new ComputerPlayer('X'));

            Player notExpected = new ComputerPlayer('X');
            Assert.AreNotEqual(notExpected, target.xPlayer);
            Assert.AreNotEqual(notExpected, target.oPlayer);
        }
 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);
 }
Ejemplo n.º 6
0
 public Game MakeGame(string parameters)
 {
     switch (parameters)
     {
         case "human":
             game = new Game(new HumanPlayer(), new HumanPlayer());
             break;
         case "computer":
             if (presenter.HumanGoesFirst())
             {
                 game = new Game(new HumanPlayer(), new ComputerPlayer());
             }
             else
             {
                 game = new Game(new ComputerPlayer(), new HumanPlayer());
             }
             break;
         case "computers":
             game = new Game(new ComputerPlayer(), new ComputerPlayer());
             break;
     }
     return game;
 }
Ejemplo n.º 7
0
        public void ShouldNotBeAbleToMakeTwoPlayersWithIdenticalIdentities()
        {
            Game target = new Game();
            target.AddPlayer(new HumanPlayer('X'));
            target.AddPlayer(new HumanPlayer('X'));

            Assert.AreEqual(null, target.oPlayer);

            target = new Game(new HumanPlayer('X'), new HumanPlayer('O'), new BoardManager());
            target.RewritePlayer(new ComputerPlayer('O'));
            Assert.AreEqual(new HumanPlayer('X'), target.xPlayer);

            target = new Game(new HumanPlayer('X'), new HumanPlayer('O'), new BoardManager());
            target.RewritePlayer(new ComputerPlayer('X'));
            Assert.AreEqual(new HumanPlayer('O'), target.oPlayer);

            target = new Game(new HumanPlayer('X'), new HumanPlayer('O'), new BoardManager());
            Assert.AreEqual(new HumanPlayer('O'), target.oPlayer);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 9
0
        public void RewritePlayerWillRewritePlayers()
        {
            Game target = new Game();
            target.AddPlayer(new HumanPlayer('X'));
            target.AddPlayer(new HumanPlayer('O'));
            target.RewritePlayer(new ComputerPlayer('X'));

            Player expected = new ComputerPlayer('X');

            Assert.AreEqual(expected, target.xPlayer);

            target.RewritePlayer(new ComputerPlayer('O'));
            expected = new ComputerPlayer('O');

            Assert.AreEqual(expected, target.oPlayer);
        }
Ejemplo n.º 10
0
 public void GameShouldBeAbleToForceMovesForInactivePlayers()
 {
     Game target = new Game(new HumanPlayer('X'), new HumanPlayer('O'));
     target.ForceMove();
 }
Ejemplo n.º 11
0
 public void GameManagerFullConstructorTest()
 {
     Game target = new Game(new HumanPlayer('X'), new HumanPlayer('Y'), new BoardManager());
 }
Ejemplo n.º 12
0
 public void GameShouldBeAbleToLogMoves()
 {
     Game target = new Game(new HumanPlayer('X'), new HumanPlayer('O'), new BoardManager());
     target.LogMove(new Tuple<int,int>(1,1));
     char actual = target.board.boardArray[1, 1];
     char expected = 'X';
     Assert.AreEqual(expected, actual);
 }
 public void BoardManagerShouldTrackNumberOfMoves()
 {
     Game target = new Game(new HumanPlayer('X'), new HumanPlayer('O'));
     target.LogMove(new Tuple<int, int>(1, 1));
     Assert.AreEqual(1, target.board.movesMade);
 }
 public void AreTwoGamesEqual(Game actual, Game expected)
 {
     Assert.AreEqual(actual.xPlayer, expected.xPlayer);
     Assert.AreEqual(actual.oPlayer, expected.oPlayer);
     CollectionAssert.AreEqual(actual.board.boardArray, expected.board.boardArray);
 }
        public void ShouldBeAbleToTakeGameParamsFromPresenter()
        {
            GameManager target = new GameManager();
            target.MakeGame("computers");
            Game actual = target.game;
            Game expected = new Game(new ComputerPlayer(), new ComputerPlayer());
            AreTwoGamesEqual(actual, expected);

            target.MakeGame("human");
            actual = target.game;
            expected = new Game(new HumanPlayer(), new HumanPlayer());
            AreTwoGamesEqual(actual, expected);

            target.MakeGame("computer");
            actual = target.game;
            expected = new Game(new HumanPlayer(), new ComputerPlayer());
        }
Ejemplo n.º 16
0
 public void GameManagerEmptyConstructorTest()
 {
     Game target = new Game();
 }
Ejemplo n.º 17
0
 public void GameShouldKnowWhoIsActivePlayer()
 {
     Game target = new Game(new HumanPlayer(), new ComputerPlayer());
     char actual = target.GetActivePlayerID();
     char expected = 'X';
     Assert.AreEqual(expected, actual);
     target.LogMove(new Tuple<int, int>(1, 1));
     actual = target.GetActivePlayerID();
     expected = 'O';
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 18
0
 public void NextMoveShouldCallMakeMoveOfAppropriatePlayer()
 {
     Game target = new Game(new HumanPlayer('X'), new ComputerPlayer('O'));
     Tuple<int,int> actual = target.NextMove();
     Tuple<int,int> expected = null;
     Assert.AreEqual(expected, actual);
     target.LogMove(new Tuple<int, int>(1, 1));
     actual = target.NextMove();
     Tuple<int, int> notExpected = null;
     Assert.AreNotEqual(notExpected, actual);
 }
Ejemplo n.º 19
0
 public void ResetGameShouldBlankAllValues()
 {
     Game target = new Game(new HumanPlayer('X'), new HumanPlayer('O'), new BoardManager());
     target.LogMove(new Tuple<int,int>(1,1));
     target.LogMove(new Tuple<int,int>(1,1));
     target.ResetGame();
     Assert.AreEqual(null, target.xPlayer);
     Assert.AreEqual(null, target.oPlayer);
     CollectionAssert.AreEqual(new char[3, 3], target.board.boardArray);
 }
Ejemplo n.º 20
0
 public void GameShouldBeAbleToGetBoardArray()
 {
     Game target = new Game(new HumanPlayer(), new HumanPlayer());
     char[,] actual = target.GetBoard();
     char[,] expected = new char[3, 3];
     CollectionAssert.AreEqual(expected, actual);
     target.LogMove(new Tuple<int, int>(1, 1));
     expected[1, 1] = 'X';
     CollectionAssert.AreEqual(expected, actual);
 }
Ejemplo n.º 21
0
 public Game MakeGame()
 {
     game = new Game();
     return game;
 }