public void GameManagerShouldBeAbleToReportOnWinsAndTies()
        {
            GameManager target = new GameManager();
            target.MakeGame("human");
            target.game.board.ForceMove(new Tuple<int, int>(0, 0), 'X');
            target.game.board.ForceMove(new Tuple<int, int>(1, 0), 'X');
            target.game.board.ForceMove(new Tuple<int, int>(2, 0), 'X');
            target.ReportGameEnd();

            target = new GameManager();
            target.MakeGame("human");
            target.game.board.ForceMove(new Tuple<int, int>(0, 0), 'O');
            target.game.board.ForceMove(new Tuple<int, int>(1, 0), 'O');
            target.game.board.ForceMove(new Tuple<int, int>(2, 0), 'O');
            target.ReportGameEnd();

            target = new GameManager();
            target.MakeGame("human");
            target.game.board.LogMove(new Tuple<int, int>(1, 1));
            target.game.board.LogMove(new Tuple<int, int>(0, 0));
            target.game.board.LogMove(new Tuple<int, int>(0, 1));
            target.game.board.LogMove(new Tuple<int, int>(2, 1));
            target.game.board.LogMove(new Tuple<int, int>(0, 2));
            target.game.board.LogMove(new Tuple<int, int>(2, 0));
            target.game.board.LogMove(new Tuple<int, int>(1, 0));
            target.game.board.LogMove(new Tuple<int, int>(1, 2));
            target.game.board.LogMove(new Tuple<int, int>(2, 2));
            target.ReportGameEnd();
        }
 public void GameManagerShouldBeAbleToMakeAGame()
 {
     GameManager target = new GameManager();
     Game actual = target.MakeGame();
     Game expected = new Game();
     AreTwoGamesEqual(actual, expected);
 }
Ejemplo n.º 3
0
 public void fauxInputTest()
 {
     GameManager testManager = new GameManager(new PresentationManager(new TestIO()));
     TestIO io = (TestIO)testManager.presenter.IO;
     io.desiredInString = "human";
     testManager.MakeGame(testManager.presenter.WelcomeAndAskForGameParams());
     Assert.AreEqual(testManager.game.xPlayer.GetType(), typeof(HumanPlayer));
     Assert.AreEqual(testManager.game.oPlayer.GetType(), typeof(HumanPlayer));
     testManager.game.board.ForceMove(new Tuple<int,int>(0,0), 'X');
     testManager.game.board.ForceMove(new Tuple<int,int>(1,0), 'X');
     testManager.game.board.ForceMove(new Tuple<int,int>(2,0), 'X');
     testManager.ReportGameEnd();
     StringAssert.Equals("X's Win!", io.lastOutString);
 }
 public void ShouldBeAbleToGetTupleOfNextMove()
 {
     GameManager target = new GameManager();
     target.MakeGame("computer");
     Tuple<int,int> actual = target.GetNextTuple();
     Tuple<int, int> expected = new Tuple<int, int>(0, 0);
     Assert.AreEqual(expected, actual);
     target.LogMove(actual);
     actual = target.GetNextTuple();
     Assert.AreNotEqual(expected, actual);
 }
        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());
        }
 public void ShouldBeAbleToLogAMove()
 {
     GameManager target = new GameManager();
     target.MakeGame("computer");
     Tuple<int, int> XatOneOne = new Tuple<int, int>(1, 1);
     target.LogMove(XatOneOne);
     char actual = target.game.board.boardArray[1, 1];
     char expected = 'X';
     Assert.AreEqual(expected, actual);
     Tuple<int, int> OatZeroZero = new Tuple<int, int>(0, 0);
     target.LogMove(OatZeroZero);
     actual = target.game.board.boardArray[0, 0];
     expected = 'O';
     Assert.AreEqual(expected, actual);
 }