public ReadOnlyConditionGroup(AbstractConditionGroup sourceGroup)
            : base(sourceGroup)
        {
            this.sourceGroup = sourceGroup;

            If = new ReadOnlyExpressionCondition(sourceGroup.If);

            sourceGroup.PropertyChanged += OnSourcePropertyChanged;
            if (null != sourceGroup.Else)
            {
                Else = new ReadOnlyBasicCondition(sourceGroup.Else);
            }
        }
        public void ReadOnlyConditionFollowsRuleChange()
        {
            bool propertyChanged = false;

            ExpressionCondition parentCondition = new ExpressionCondition() { Expression = "test > 1" };

            ReadOnlyExpressionCondition childCondition = new ReadOnlyExpressionCondition(parentCondition);
            childCondition.PropertyChanged += (o, e) => propertyChanged = (e.PropertyName == "Expression");

            Assert.AreEqual("test > 1", childCondition.Expression);

            parentCondition.Expression = "test <= 1";

            Assert.IsTrue(propertyChanged);
            Assert.AreEqual("test <= 1", childCondition.Expression);
        }
        public void AddReadOnlyAction()
        {
            ExpressionCondition parentCondition = new ExpressionCondition() { Expression = "test > 1" };
            ReadOnlyExpressionCondition childCondition = new ReadOnlyExpressionCondition(parentCondition);

            parentCondition.AddStatement(new Action(Workspace.Instance.GetPlugin(FireTriggerActionType)));

            Assert.AreEqual(1, childCondition.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);
        }