public void RemoveInheritedAction() { int parentEventsRaised = 0; int childEventsRaised = 0; Event parentEvent = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType)); parentEvent.Statements.CollectionChanged += (sender, e) => parentEventsRaised++; Action parentAction = new Action(Workspace.Instance.GetPlugin(FireTriggerActionType)); parentEvent.AddStatement(parentAction); ReadOnlyEvent childEvent = new ReadOnlyEvent(parentEvent); childEvent.Statements.CollectionChanged += (sender, e) => childEventsRaised++; Assert.AreEqual(1, childEvent.Statements.Count); parentEvent.RemoveStatement(parentAction); Assert.AreEqual(0, childEvent.Statements.Count); Assert.AreEqual(2, parentEventsRaised); Assert.AreEqual(1, childEventsRaised); }
public void RemoveLocalAction() { int eventsRaised = 0; Event evt = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType)); evt.Statements.CollectionChanged += (sender, e) => eventsRaised++; Action action = new Action(Workspace.Instance.GetPlugin(FireTriggerActionType)); evt.AddStatement(action); evt.RemoveStatement(action); Assert.AreEqual(2, eventsRaised); Assert.AreEqual(0, evt.Statements.Count); }
public void RemoveConditionGroup() { int eventsFired = 0; Event evt = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType)); evt.Statements.CollectionChanged += (o, e) => eventsFired++; ConditionGroup group = new ConditionGroup(); evt.AddStatement(group); evt.RemoveStatement(group); Assert.AreEqual(2, eventsFired); Assert.AreEqual(0, evt.Statements.Count); }