Esempio n. 1
0
        public void DuplicateTest()
        {
            //Create a new board and make a move in it
            TTTBoard boardA = new TTTBoard();

            boardA.MakeMove(new TTTMove(1, 1));

            //Duplicate the board and store it in a new board instance
            TTTBoard boardB = (TTTBoard)boardA.Duplicate();

            //Ensure the move made before duplication is present in both boards
            Assert.AreEqual(1, boardA.GetCell(1, 1));
            Assert.AreEqual(1, boardB.GetCell(1, 1));

            //These two board instances should share no memory, lets prove it by making moves in each of them and checking the other
            boardA.MakeMove(new TTTMove(2, 0));
            Assert.AreEqual(2, boardA.GetCell(2, 0));
            Assert.AreEqual(0, boardB.GetCell(2, 0));

            boardB.MakeMove(new TTTMove(1, 2));
            Assert.AreEqual(0, boardA.GetCell(1, 2));
            Assert.AreEqual(2, boardB.GetCell(1, 2));
        }