示例#1
0
        public void UndoAfterExecuteTest()
        {
            //Arrange
            int getValue = 42;

            Quest quest      = QuestHelper.CreateQuest();
            Quest questToSet = null;
            int   valueToSet = default(int);

            MockPropertyChangeQuestCommand command = new MockPropertyChangeQuestCommand();

            command.OnGetPropertyValue += q => getValue;
            command.OnActionOnQuest    += (q, ov) => { };
            command.OnSetPropertyValue += (q, v) =>
            {
                questToSet = q;
                valueToSet = v;
            };

            //Act
            command.Execute(quest);
            bool undoResult = command.Undo(quest);

            //Assert
            Assert.IsTrue(undoResult);
            Assert.AreEqual(quest, questToSet);
            Assert.AreEqual(getValue, valueToSet);
        }
示例#2
0
        public void UndoWithoutExecuteTest()
        {
            //Arrange
            int   setPropertyCalledValue = 0;
            Quest quest = QuestHelper.CreateQuest();

            MockPropertyChangeQuestCommand command = new MockPropertyChangeQuestCommand();

            command.OnSetPropertyValue += (q, v) => { setPropertyCalledValue++; };

            //Act
            bool undoResult = command.Undo(quest);

            //Assert
            Assert.IsFalse(undoResult);
            Assert.AreEqual(0, setPropertyCalledValue);
        }