public void AddAction() { bool collectionChanged = false; ExpressionCondition condition = new ExpressionCondition() { Expression = "test > 1" }; condition.Statements.CollectionChanged += (o, e) => collectionChanged = true; Action action = new Action(Workspace.Instance.GetPlugin(FireTriggerActionType)); condition.AddStatement(action); Assert.IsTrue(collectionChanged); Assert.AreEqual(1, condition.Statements.Count); }
public void AddLocalAction() { 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); Assert.AreEqual(1, eventsRaised); Assert.IsTrue(action.IsEditable); Assert.AreEqual(1, evt.Statements.Count); }
public void CannotRemoveInheritedActionFromInheritingEvent() { Event parentEvent = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType)); Action parentAction = new Action(Workspace.Instance.GetPlugin(FireTriggerActionType)); parentEvent.AddStatement(parentAction); ReadOnlyEvent childEvent = new ReadOnlyEvent(parentEvent); Assert.AreEqual(1, childEvent.Statements.Count); AbstractStatement childAction = childEvent.Statements.Single(); childEvent.RemoveStatement(childAction); Assert.AreEqual(1, childEvent.Statements.Count); }
public void SetActionProperty() { bool propertyFiredValueChange = false; Action action = new Action(Workspace.Instance.GetPlugin(FireTriggerActionType)); action.GetProperty("Name").PropertyChanged += (sender, e) => propertyFiredValueChange |= (e.PropertyName == "Value"); action.SetProperty("Name", new Value("test", true)); Assert.IsTrue(propertyFiredValueChange); Assert.AreEqual("test", action.GetProperty("Name").Value.Reader.GetStrValue()); }
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 InheritedActionPropertyFollowsSource() { bool childPropertyChanged = false; Event parentEvent = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType)); Action parentAction = new Action(Workspace.Instance.GetPlugin(FireTriggerActionType)); parentAction.SetProperty("Name", new Value("test", true)); parentEvent.AddStatement(parentAction); ReadOnlyEvent childEvent = new ReadOnlyEvent(parentEvent); AbstractProperty childProperty = ((AbstractAction)childEvent.Statements.Single()).GetProperty("Name"); childProperty.PropertyChanged += (sender, e) => childPropertyChanged |= (e.PropertyName == "Value"); parentAction.SetProperty("Name", new Value("test2", true)); Assert.AreEqual("test2", childProperty.Value.Reader.GetStrValue()); Assert.IsTrue(childPropertyChanged); }
public override sealed AbstractStatement DeepCopyStatement() { Action copy = new Action(this.Plugin); foreach (AbstractProperty property in this.Properties) { copy.SetProperty(property.Name, property.Value); } return copy; }
public void RemoveReadOnlyAction() { ExpressionCondition parentCondition = new ExpressionCondition() { Expression = "test > 1" }; ReadOnlyExpressionCondition childCondition = new ReadOnlyExpressionCondition(parentCondition); Action parentAction = new Action(Workspace.Instance.GetPlugin(FireTriggerActionType)); parentCondition.AddStatement(parentAction); parentCondition.RemoveStatement(parentAction); Assert.AreEqual(0, childCondition.Statements.Count); }
public void RemoveAction() { int eventsFired = 0; ExpressionCondition condition = new ExpressionCondition() { Expression = "test > 1" }; condition.Statements.CollectionChanged += (o, e) => eventsFired++; Action action = new Action(Workspace.Instance.GetPlugin(FireTriggerActionType)); condition.AddStatement(action); condition.RemoveStatement(action); Assert.AreEqual(2, eventsFired); Assert.AreEqual(0, condition.Statements.Count); }
public void CannotRemoveInheritedActionFromInheritingCondition() { ExpressionCondition parentCondition = new ExpressionCondition() { Expression = "test > 1" }; ReadOnlyExpressionCondition childCondition = new ReadOnlyExpressionCondition(parentCondition); Action parentAction = new Action(Workspace.Instance.GetPlugin(FireTriggerActionType)); parentCondition.AddStatement(parentAction); AbstractStatement childAction = childCondition.Statements.Single(); childCondition.RemoveStatement(childAction); Assert.AreEqual(1, childCondition.Statements.Count); }