Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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());
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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;
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
        }