public void UndoOnQuestWithChildrenTest() { //Arrange Quest child = new FakeQuest(); Quest quest = new FakeQuest() { Children = new List <Quest>() { child, null } }; int undoOnParentCount = 0; int undoOnChildCount = 0; int undoAfterTraverseParentCount = 0; int undoAfterTraverseChildCount = 0; MockDownHierarchyQuestCommand command = new MockDownHierarchyQuestCommand(quest); command.OnUndoOnQuest += (q) => { if (q == quest) { undoOnParentCount++; } if (q == child) { undoOnChildCount++; } }; command.OnUndoOnQuestAfterTraverse += (q) => { if (q == quest) { undoAfterTraverseParentCount++; } if (q == child) { undoAfterTraverseChildCount++; } }; //Act command.Execute(); command.Undo(); //Assert Assert.AreEqual(1, undoOnParentCount); Assert.AreEqual(1, undoOnChildCount); Assert.AreEqual(1, undoAfterTraverseParentCount); Assert.AreEqual(0, undoAfterTraverseChildCount); }
public void ExecuteOnQuestWithoutChildrenTest() { //Arrange Quest quest = new FakeQuest(); MockDownHierarchyQuestCommand command = new MockDownHierarchyQuestCommand(quest); command.OnExecuteOnQuest += (q) => { Assert.AreEqual(quest, q); }; //Act command.Execute(); //Assert }