public void BoardManagerShouldBeAbleToCheckTheValidityOfAMove() { BoardManager target = new BoardManager(); target.LogMove(new Tuple<int, int>(1, 1)); bool expected = false; bool actual = target.IsMoveValid(new Tuple<int, int>(1, 1)); 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 MakeMoveShouldGetRandomMoveOfMovesAvailable() { BoardManager board = new BoardManager(); ComputerPlayer playerTwo = new ComputerPlayer('O'); board.LogMove(new Tuple<int,int>(1,1)); Tuple<int,int> playerChoice = playerTwo.MakeMove(board.boardArray); CreatedMove actual = new CreatedMove(playerChoice.Item1, playerChoice.Item2,playerTwo.identity); 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 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 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 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)); }
public void LogMoveShouldNotOverwriteMoves() { BoardManager target = new BoardManager(); target.LogMove(new Tuple<int, int>(1, 1)); target.LogMove(new Tuple<int, int>(1, 1)); char expectedIdentity = 'X'; char actualIdentity = target.boardArray[1, 1]; Assert.AreEqual(expectedIdentity, actualIdentity); }
public void LogMoveShouldLogACreatedMove() { BoardManager target = new BoardManager(); target.LogMove(new Tuple<int, int>(1, 1)); char actual = target.boardArray[1, 1]; char expected = 'X'; Assert.AreEqual(expected, actual); }
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)); }