Example #1
0
        public void ValidateBoardHistory_DrawTurns_Expect_Draw()
        {
            int boardHistory = 0;

            for (int i = 0; i < s_drawTurns.Length; i++)
            {
                boardHistory = BoardHistoryUtils.SetTurn(boardHistory, i, s_drawTurns[i]);
            }

            BoardHistoryUtils.ValidateBoardHistory(boardHistory, out _, out _, out _, out var boardResult);

            Assert.AreEqual(BoardResult.Draw, boardResult);
        }
Example #2
0
        public void ValidateBoardHistory_QuickWinPlayerTwoTurns_Expect_WinPlayerTwo()
        {
            int boardHistory = 0;

            for (int i = 0; i < s_quickWinPlayerTwoTurns.Length; i++)
            {
                boardHistory = BoardHistoryUtils.SetTurn(boardHistory, i, s_quickWinPlayerTwoTurns[i]);
            }

            BoardHistoryUtils.ValidateBoardHistory(boardHistory, out _, out _, out _, out var boardResult);

            Assert.AreEqual(BoardResult.WinPlayerTwo, boardResult);
        }
Example #3
0
        public void ValidateBoardHistory_TurnsHistoryAfterEndingState_Expect_Error()
        {
            int boardHistory = 0;

            for (int i = 0; i < s_quickWinPlayerOneTurns.Length; i++)
            {
                boardHistory = BoardHistoryUtils.SetTurn(boardHistory, i, s_quickWinPlayerOneTurns[i]);
            }

            boardHistory = BoardHistoryUtils.SetTurn(boardHistory, s_quickWinPlayerOneTurns.Length + 1, 0);

            var ex = Assert.Throws <ArgumentException>(() => BoardHistoryUtils.ValidateBoardHistory(boardHistory, out _, out _, out _, out _));

            Assert.AreEqual("Turn history exists after a ending state was reached", ex.Message);
        }
Example #4
0
        // [TestCase(8)] Can't sequence break on final turn
        public void ValidateBoardHistory_SequenceBreakState_Expect_Error(int sequenceBreakTurnIndex)
        {
            int boardHistory = 0;

            for (int i = 0; i <= sequenceBreakTurnIndex + 1; i++)
            {
                if (i != sequenceBreakTurnIndex)
                {
                    boardHistory = BoardHistoryUtils.SetTurn(boardHistory, i, s_drawTurns[i]);
                }
            }

            var ex = Assert.Throws <ArgumentException>(() => BoardHistoryUtils.ValidateBoardHistory(boardHistory, out _, out _, out _, out _));

            Assert.AreEqual("Sequence of turns is invalid", ex.Message);
        }
Example #5
0
        // [TestCase(8)] Optimizations always truncate this turn into a valid range
        public void ValidateBoardHistory_DeltaIndexOutOfBoundsState_Expect_Error(int outOfBoundsTurnIndex)
        {
            int boardHistory = 0;

            for (int i = 0; i <= outOfBoundsTurnIndex; i++)
            {
                if (i == outOfBoundsTurnIndex)
                {
                    boardHistory = BoardHistoryUtils.SetTurn(boardHistory, i, 9 - i);
                }
                else
                {
                    boardHistory = BoardHistoryUtils.SetTurn(boardHistory, i, s_drawTurns[i]);
                }
            }

            var ex = Assert.Throws <ArgumentException>(() => BoardHistoryUtils.ValidateBoardHistory(boardHistory, out _, out _, out _, out _));

            Assert.AreEqual("Turn delta index is out of bounds", ex.Message);
        }