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); }
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); }