protected override CodeblockSystem BuildSystem()
        {
            CodeblockSystem system = new CodeblockSystem();

            DynamicInputOperator <int>[] inputs = new DynamicInputOperator <int> [4];
            for (int i = 0; i < 4; i++)
            {
                DynamicInputOperator <int> input = new DynamicInputOperator <int>();
                input.Value = i * 2;
                inputs[i]   = input;
            }

            ComparisonOperationCodeblock left = new ComparisonOperationCodeblock()
            {
                Left      = inputs[0],
                Right     = inputs[1],
                Operation = ComparisonOperation.SmallerOrEqual
            };
            ComparisonOperationCodeblock right = new ComparisonOperationCodeblock()
            {
                Left      = inputs[2],
                Right     = inputs[3],
                Operation = ComparisonOperation.Equal
            };

            LogicOperationCodeblock logic = new LogicOperationCodeblock()
            {
                Left      = left,
                Right     = right,
                Operation = LogicalOperation.OR
            };

            AssertTestBlock ifTrue = new AssertTestBlock();

            ifTrue.Condition = () => true;

            AssertTestBlock ifFalse = new AssertTestBlock();

            ifFalse.Condition = () => false;

            IfElseBlock ifElseBlock = new IfElseBlock();

            ifElseBlock.Condition = logic;

            ifElseBlock.Children.InsertItem(ifTrue, null);
            ifElseBlock.ElseChildren.InsertItem(ifFalse, null);

            system.Blocks.InsertItem(ifElseBlock, null);

            return(system);
        }
Exemple #2
0
        public void ComparisonOperations()
        {
            ComparisonOperationCodeblock block = new ComparisonOperationCodeblock();

            block.Arguments[0].SetEvaluateable(new ConstantEvaluateable(4));
            block.Arguments[2].SetEvaluateable(new ConstantEvaluateable(3));

            block.Arguments[1].SetEvaluateable(new ConstantEvaluateable(ComparisonOperator.Equal));
            Assert.False(Convert.ToBoolean(block.Evaluate().Value));

            block.Arguments[1].SetEvaluateable(new ConstantEvaluateable(ComparisonOperator.GreaterThanOrEqual));
            Assert.True(Convert.ToBoolean(block.Evaluate().Value));

            block.Arguments[1].SetEvaluateable(new ConstantEvaluateable(ComparisonOperator.LessThan));
            Assert.False(Convert.ToBoolean(block.Evaluate().Value));
        }
        protected override CodeblockSystem BuildSystem()
        {
            CodeblockSystem system = new CodeblockSystem();

            AssertTestBlock ifTrue = new AssertTestBlock();

            ifTrue.Condition = () => true;

            AssertTestBlock ifFalse = new AssertTestBlock();

            ifFalse.Condition = () => false;

            var left = new DynamicInputOperator <float>();

            left.Value = 5;
            var right = new DynamicInputOperator <string>();

            right.Value = "1";

            ComparisonOperationCodeblock coc = new ComparisonOperationCodeblock();

            coc.Operation = ComparisonOperation.GreaterThan;
            coc.Left      = left;
            coc.Right     = right;

            IfElseBlock ifelse = new IfElseBlock();

            ifelse.Condition = coc;

            ifelse.Children.InsertItem(ifTrue, null);
            ifelse.ElseChildren.InsertItem(ifFalse, null);

            system.Blocks.InsertItem(ifelse, null);

            return(system);
        }