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 CannotSetPropertyForInheritedAction() { int parentEventsRaised = 0; bool parentPropertyChanged = false; bool childPropertyChanged = false; Event parentEvent = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType)); parentEvent.Statements.CollectionChanged += (sender, e) => parentEventsRaised++; Action parentAction = new Action(Workspace.Instance.GetPlugin(FireTriggerActionType)); parentAction.GetProperty("Name").PropertyChanged += (sender, e) => parentPropertyChanged |= (e.PropertyName == "Value"); 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"); childProperty.Value = new Value("test2", true); Assert.AreEqual("test", childProperty.Value.Reader.GetStrValue()); Assert.AreEqual(1, parentEventsRaised); Assert.IsTrue(parentPropertyChanged); Assert.IsFalse(childPropertyChanged); }