Пример #1
0
        public void BoardRestoreMementoShouldRestoreBoardToPreviousState()
        {
            var board = new Board(5, 5, this.randomGenerator);
            var memento = board.SaveMemento();

            board[0, 0] = null;
            board[1, 1] = null;
            board[1, 0] = null;

            board.RestoreMemento(memento);

            if (board[0, 0] != null && board[1, 1] != null && board[1, 0] != null)
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail();
            }
        }
Пример #2
0
        public void BoardSaveMementoShouldReturnAMemento()
        {
            var board = new Board(5, 5, this.randomGenerator);
            var memento = board.SaveMemento().Board;

            var boardAsMatrix = new IBalloon[5, 5];

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    boardAsMatrix[i, j] = board[i, j];
                }
            }

            var anotherMemento = new Memento(boardAsMatrix).Board;

            Assert.AreEqual(memento, anotherMemento);
        }