Exemplo n.º 1
0
        public void TestConnectorProperties()
        {
            var obj = new ConstantExpression();
            TestsHelper.TestPublicPropertiesGetSet(obj);

            Assert.IsNotNull(obj.ConnectorOut);
        }
Exemplo n.º 2
0
        public void GetConnectorsTest()
        {
            var source = new ConstantExpression
                             {
                                 ConnectorOut = {Name = "4"}
                             };

            var conn = source.GetConnectors();
            Assert.IsTrue(conn.Any(x => x.Name == "4"));
        }
Exemplo n.º 3
0
        public void IsValidTest()
        {
            var source = new ConstantExpression();

            Assert.IsFalse(source.IsValid);
            
            Assert.IsFalse(source.IsValid);

            source.ConnectorOut.ConnectedTo = new ConnectorIn(null);
            Assert.IsTrue(source.IsValid);
        }
Exemplo n.º 4
0
        public void CloneTest()
        {
            var source = new ConstantExpression {ExpressionName = "source", Width = 1, Height = 2, Top = 3, Left = 4, ConnectorOut = {Name = "4"}};

            var cloneTo = (ConstantExpression)source.Clone();
            Assert.AreEqual(source.ExpressionName, cloneTo.ExpressionName);
            Assert.AreEqual(source.Width, cloneTo.Width);
            Assert.AreEqual(source.Height, cloneTo.Height);
            Assert.AreEqual(source.Top, cloneTo.Top);
            Assert.AreEqual(source.Left, cloneTo.Left);

            Assert.AreNotEqual(source.Id, cloneTo.Id);
            Assert.AreNotEqual(source.ConnectorOut.Id, cloneTo.ConnectorOut.Id);

            Assert.AreEqual(source.ConnectorOut.Name, cloneTo.ConnectorOut.Name);
        }
        public void WhenInputConnectorIsConnected_SecondOutputConnectorDataTypeIsUpdated()
        {
            // Arrange.
            var expression = new SetChecklistDataExpression();
            var source = new ConstantExpression { ConnectorOut = { ElementType = NodeDataType.Boolean } };

            // Act.
            expression.ConnectorIn.ConnectedTo = source.ConnectorOut;

            // Assert.
            Assert.AreEqual(NodeDataType.Boolean, expression.Connector2Out.DataType);

            // Act.
            expression.ConnectorIn.ConnectedTo = null;

            // Assert.
            Assert.AreEqual(NodeDataType.Object, expression.Connector2Out.DataType);
        }
        public void WhenFirstInputConnectorIsConnected_OutputConnectorDataTypeIsUpdated()
        {
            // Arrange.
            var functionExpression = new GetArrayItemExpression();
            var source = new ConstantExpression { ConnectorOut = { ElementType = NodeDataType.DateTime } };

            // Act.
            functionExpression.Connector1In.ConnectedTo = source.ConnectorOut;

            // Assert.
            Assert.AreEqual(NodeDataType.DateTime, functionExpression.ConnectorOut.DataType);

            // Act.
            functionExpression.Connector1In.ConnectedTo = null;

            // Assert.
            Assert.AreEqual(NodeDataType.Object, functionExpression.ConnectorOut.DataType);
        }
Exemplo n.º 7
0
        public void WhenFirstInputConnectorIsConnected_OutputConnectorElementTypeIsUpdated()
        {
            // Arrange.
            var expression = new SkipItemsExpression();
            var source = new ConstantExpression { ConnectorOut = { ElementType = NodeDataType.String } };

            // Act.
            expression.Connector1In.ConnectedTo = source.ConnectorOut;

            // Assert.
            Assert.AreEqual(NodeDataType.String, expression.ConnectorOut.ElementType);

            // Act.
            expression.Connector1In.ConnectedTo = null;

            // Assert.
            Assert.AreEqual(NodeDataType.Object, expression.ConnectorOut.ElementType);
        }
        public void CreateDestinationNodeShouldReturnDestinationNode()
        {
            var obj = new ExpressionNodeFactory();

            var destination = new DestinationFieldList { UniqueName = "Destination" };
            destination.Fields.Add(new DestinationField(destination));
            var source = new ConstantExpression();
            var connection = new Connection { Source = source.ConnectorOut, Sink = destination.Fields[0].ConnectorIn };

            var objects = new List<IExpressionObjectBase>
                              {   
                                  source,
                                  destination,
                                  connection
                              };

            Assert.IsNotNull(obj.CreateDestinationNode(objects, "Destination"));
        }
Exemplo n.º 9
0
        public void TestConnectorSerialization()
        {
            var obj = new ConstantExpression {Value = "test"};

            var tw = new StringWriter();
            using (var xw = XmlWriter.Create(tw))
            {
                xw.WriteStartElement("Node");
                obj.Serialize(xw);
                xw.WriteEndElement();
            }

            var sr = new StringReader(tw.ToString());
            using (var wr = XmlReader.Create(sr))
            {
                wr.ReadToFollowing("Node");
                var result = new ConstantExpression();
                result.Deserialize(wr);

                Assert.AreEqual(obj.Id, result.Id);
                Assert.AreEqual(obj.ConnectorOut.Id, result.ConnectorOut.Id);
                Assert.AreEqual(obj.Value, result.Value);
            }
        }
Exemplo n.º 10
0
        private static void SetupExpressionsDiagram(DiagramViewModel vm)
        {
            vm.Palette.Add(new NodeGroup("String Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.ToUpper)
                                                        {
                                                            ExpressionName = "Uppercase",
                                                            ConnectorIn =  { DataType = NodeDataType.String, Name = "String" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.ToLower)
                                                        {
                                                            ExpressionName = "Lowercase",
                                                            ConnectorIn =  { DataType = NodeDataType.String, Name = "String" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.Trim)
                                                        {
                                                            ExpressionName = "Trim",
                                                            ConnectorIn =  { DataType = NodeDataType.String, Name = "String" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Concat)
                                                        {
                                                            ExpressionName = "Concat",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "String 1" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "String 2" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Left)
                                                        {
                                                            ExpressionName = "Left",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "String 1" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "String 2" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } 
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Right)
                                                        {
                                                            ExpressionName = "Right",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "String 1" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "String 2" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    )
                                                }));

            vm.Palette.Add(new NodeGroup("Date Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.AddDays)
                                                        {
                                                            ExpressionName = "Add Days",
                                                            Connector1In = { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Days Count" },
                                                            ConnectorOut = { DataType = NodeDataType.DateTime, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.DateDiffDays)
                                                        {
                                                            ExpressionName = "DateDiff Days",
                                                            Connector1In = { DataType = NodeDataType.DateTime, Name = "Date 1" },
                                                            Connector2In = { DataType = NodeDataType.DateTime, Name = "Date 2" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.DateDiffHours)
                                                        {
                                                            ExpressionName = "DateDiff Hours",
                                                            Connector1In = { DataType = NodeDataType.DateTime, Name = "Date 1" },
                                                            Connector2In = { DataType = NodeDataType.DateTime, Name = "Date 2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FunctionExpressionNode, ExpressionConnection>(
                                                        new FunctionExpressionNode(vm, new FunctionExpression(ExpressionNodeType.CustomFunction)
                                                        {
                                                            ExpressionName = "Current Date",
                                                            FunctionName = "DateTime.Now",
                                                            ConnectorOut = { DataType = NodeDataType.DateTime, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateYear)
                                                        {
                                                            ExpressionName = "Date Year",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Year" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateQuarter)
                                                        {
                                                            ExpressionName = "Date Quarter",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Quarter" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateMonth)
                                                        {
                                                            ExpressionName = "Date Month",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Month" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateMonthName)
                                                        {
                                                            ExpressionName = "Date Month Name",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Month Name" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateWeek)
                                                        {
                                                            ExpressionName = "Date Week",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Week" }
                                                        }),
                                                        vm
                                                    ),

                                                }));

            vm.Palette.Add(new NodeGroup("Logical Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.IsLess)
                                                        {
                                                            ExpressionName = "Less",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "a" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "b" },
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.IsGreater)
                                                        {
                                                            ExpressionName = "Greater",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "a" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "b" },
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.AreEqual)
                                                        {
                                                            ExpressionName = "Equals",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "a" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "b" },
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<ThreeInOneOutExpressionNode, ExpressionConnection>(
                                                        new ThreeInOneOutExpressionNode(vm, new ThreeInOneOutExpression(ExpressionNodeType.If)
                                                        {
                                                            ExpressionName = "Condition",
                                                            Connector1In = { DataType = NodeDataType.Boolean, Name = "Condition" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "When True"  },
                                                            Connector3In = { DataType = NodeDataType.String, Name = "When False" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                }));

            vm.Palette.Add(new NodeGroup("Aggregate Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Add)
                                                        {
                                                            ExpressionName = "Add", 
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1"},
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2"},
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Subtract)
                                                        { 
                                                            ExpressionName = "Subtract",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Multiply)
                                                        {
                                                            ExpressionName = "Multiply",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Divide)
                                                        {
                                                            ExpressionName = "Divide",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.CustomFunction)
                                                        {
                                                            ExpressionName = "Custom Multiply",
                                                            FunctionName = "?1 * ?2",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                }));

            vm.Palette.Add(new NodeGroup("SPC Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.AboveCenterLine)
                                                        {
                                                            ExpressionName = "Above Center Line", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.BelowCenterLine)
                                                        {
                                                            ExpressionName = "Below Center Line", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.GoingDown)
                                                        {
                                                            ExpressionName = "Going Down", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.GoingUp)
                                                        {
                                                            ExpressionName = "Going Up", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.AlternatingUpAndDown)
                                                        {
                                                            ExpressionName = "Alternating Up and Down", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>(
                                                        new SixInOneOutExpressionNode(vm, new SixInOneOutExpression(ExpressionNodeType.LessThanLowerLimits)
                                                        {
                                                            ExpressionName = "Less Than LCL/LSL", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Double, Name = "LCL/LSL"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector5In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector6In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>(
                                                        new SixInOneOutExpressionNode(vm, new SixInOneOutExpression(ExpressionNodeType.GreaterThanUpperLimits)
                                                        {
                                                            ExpressionName = "Greater Than UCL/USL", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Double, Name = "UCL/USL"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector5In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector6In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.Same)
                                                        {
                                                            ExpressionName = "Same", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>(
                                                        new SixInOneOutExpressionNode(vm, new SixInOneOutExpression(ExpressionNodeType.Between)
                                                        {
                                                            ExpressionName = "Between", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Double, Name = "Low Value"},
                                                            Connector5In = { DataType = NodeDataType.Double, Name = "High Value"},
                                                            Connector6In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>(
                                                        new FiveInOneOutExpressionNode(vm, new FiveInOneOutExpression(ExpressionNodeType.ZoneAorBeyond)
                                                        {
                                                            ExpressionName = "Zone A or beyond", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector5In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>(
                                                        new FiveInOneOutExpressionNode(vm, new FiveInOneOutExpression(ExpressionNodeType.ZoneBorBeyond)
                                                        {
                                                            ExpressionName = "Zone B or beyond", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector5In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>(
                                                        new FiveInOneOutExpressionNode(vm, new FiveInOneOutExpression(ExpressionNodeType.ZoneCorBeyond)
                                                        {
                                                            ExpressionName = "Zone C or beyond", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector5In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.FailedNumber)
                                                        {
                                                            ExpressionName = "Failed Number (attribute)", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Number of samples"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.FailedPercent)
                                                        {
                                                            ExpressionName = "Failed Percent (attribute)", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Number of samples"},
                                                            Connector3In = { DataType = NodeDataType.Double, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                }));

            vm.Palette.Add(new NodeGroup("Constants",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<ConstantExpressionNode, ExpressionConnection>(
                                                        new ConstantExpressionNode(vm, new ConstantExpression()
                                                        {
                                                            ExpressionName = "Constant",
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    )
                                                }));


            var uis = new SourceFieldList {ExpressionName = "Current User Information", Left = 10, Top = 400};
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "User Name", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserName", ConnectorOut = { DataType = NodeDataType.String, Name = "User Name" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Full Name", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserFullName", ConnectorOut = { DataType = NodeDataType.String, Name = "Full Name" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.Int, Name = "Person ID", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserPersonId", ConnectorOut = { DataType = NodeDataType.String, Name = "Person ID" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Email Address", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserEmailAddress", ConnectorOut = { DataType = NodeDataType.String, Name = "Email Address" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Last Name", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserLastName", ConnectorOut = { DataType = NodeDataType.String, Name = "Last Name" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Business Unit", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserBusinessUnitId", ConnectorOut = { DataType = NodeDataType.String, Name = "Business Unit" } });

            // source
            //var fieldList = new Dictionary<string, object>();
            //fieldList["Name"] = "Name";
            //fieldList["Title"] = "Title";
            //fieldList["PublishDate"] = DateTime.Now;
            //fieldList["Author"] = "Author";

            var sourceNodeList = new SourceFieldList();

            //Func<IExpressionField, ICollection<IExpressionField>> sfRetriever = f => GetCRFields(f, sourceNodeList);
            
            sourceNodeList.ExpressionName = "Album";
            sourceNodeList.Top = 10;
            sourceNodeList.Left = 10;
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "Name", SetName = SourceFieldSetNames.Item, SystemName = "Name", ConnectorOut = { DataType = NodeDataType.String, Name = "Name" } });
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "Title", SetName = SourceFieldSetNames.Item, SystemName = "Title", ConnectorOut = { DataType = NodeDataType.String, Name = "Title" } });
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "PublishDate", SetName = SourceFieldSetNames.Item, SystemName = "PublishDate", ConnectorOut = { DataType = NodeDataType.String, Name = "PublishDate" } });
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList)
                                          {
                                              DataType = NodeDataType.String, 
                                              Name = "Author", 
                                              SetName = SourceFieldSetNames.Item, 
                                              SystemName = "Author", 
                                              ConnectorOut = { DataType = NodeDataType.String, Name = "Author" },
                                              SubfieldsRetriever = new CRSubfieldsRetriever()
                                          });



            //var sourceNodes = SourceNodeFactory.ConvertToSource("Album", fieldList, SourceFieldSetNames.Item);
            //sourceNodes.Top = 10;
            //sourceNodes.Left = 10;
            //sourceNodes.Width = 200;

            // destination
            var destinationNodes = DestinationNodeFactory.ConvertToSource(typeof(ExpressionResult));
            destinationNodes.Top = 200;
            destinationNodes.Left = 600 ;

            var expressions = new List<IExpressionObjectBase>();
            expressions.Add(sourceNodeList);
            //expressions.Add(uis);
            expressions.Add(destinationNodes);

            // connection
            var connection = new Connection
                                 {
                                     Id = Guid.NewGuid(),
                                     Source = new ConnectorOut(null) { Id = sourceNodeList.ConnectorsOut[0].Id },
                                     Sink = new ConnectorIn(null) { Id = destinationNodes.ConnectorsIn[0].Id }
                                 };
            //expressions.Add(connection);

            // constant
            var constantExpr = new ConstantExpression { ExpressionName = "Constant", Top = 10, Left = 250, Value = 10,
                                                        ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
            };
            //expressions.Add(constantExpr);

            // oneinoneout
            var oneinoneoutExpr = new OneInOneOutExpression(ExpressionNodeType.ToUpper)
                                      { ExpressionName = "Uppercase", Top = 60, Left = 250, 
                                        ConnectorIn = {DataType = NodeDataType.String, Name = "String"},
                                        ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                      };
            //expressions.Add(oneinoneoutExpr);

            // twoinoneout
            var twoinoneoutExpr = new TwoInOneOutExpression(ExpressionNodeType.Concat)
            {
                ExpressionName = "Concat",
                Top = 110,
                Left = 250,
                Connector1In = { DataType = NodeDataType.String, Name = "String" },
                Connector2In = { DataType = NodeDataType.String, Name = "String" },
                ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
            };
            //expressions.Add(twoinoneoutExpr);

            // threeinoneout
            var threeinoneoutExpr = new ThreeInOneOutExpression(ExpressionNodeType.If)
            {
                ExpressionName = "Condition",
                Top = 180,
                Left = 250,
                Connector1In = { DataType = NodeDataType.Boolean, Name = "Condition" },
                Connector2In = { DataType = NodeDataType.String, Name = "If True" },
                Connector3In = { DataType = NodeDataType.String, Name = "If False" },
                ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
            };
            expressions.Add(threeinoneoutExpr);

            // function
            var functionExpr = new FunctionExpression(ExpressionNodeType.CustomFunction) { ExpressionName = "Current Date", Top = 280, Left = 250, Width = 100, Height = 45, FunctionName = "DateTime.Now",
                                ConnectorOut = {DataType = NodeDataType.DateTime, Name="Result"}};
            //expressions.Add(functionExpr);

            ExpressionTranslator.TranslateToDiagram(expressions, vm);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConstantExpressionNode"/> class.
        /// </summary>
        /// <param name="diagramViewModel">The diagram view model.</param>
        /// <param name="expressionObject">The expression object.</param>
        /// <exception cref="System.ArgumentNullException">expressionObject</exception>
        public ConstantExpressionNode(IDiagramViewModel diagramViewModel, ConstantExpression expressionObject)
            : base(expressionObject)
        {
            if (expressionObject == null) throw new ArgumentNullException("expressionObject");
            _diagramViewModel = diagramViewModel;

            IsValidFunc = n => true;
            UpdateAction = n => { };

            Value = expressionObject.Value;

            ConnectorOut = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.Out, expressionObject.ConnectorOut), _diagramViewModel);
        }
Exemplo n.º 12
0
        public void RestoreConnectionsShouldConnectSourceToDestAndSinkToSourve()
        {
            var obj = new ExpressionNodeFactory();
            var connection = new Connection();
            connection.Source = new ConnectorOut(connection);
            connection.Sink = new ConnectorIn(connection);

            var destination = new DestinationFieldList { UniqueName = "Destination" };
            destination.Fields.Add(new DestinationField(destination));
            var source = new ConstantExpression();

            destination.Fields[0].ConnectorIn.Id = connection.Source.Id;
            source.ConnectorOut.Id = connection.Sink.Id;

            var objects = new List<IExpressionObjectBase>
                              {   
                                  source,
                                  destination,
                                  connection
                              };

            obj.RestoreConnections(objects);

            Assert.AreSame(destination.Fields[0].ConnectorIn, connection.Sink);
            Assert.AreSame(source.ConnectorOut, connection.Source);
        }
Exemplo n.º 13
0
        public void ToExpressionNode_Constant_Test()
        {
            var obj = new ExpressionNodeFactory();

            var connection2 = new Connection();
            connection2.Source = new ConnectorOut(connection2);
            connection2.Sink = new ConnectorIn(connection2);

            var destination = new DestinationFieldList { UniqueName = "Destination" };
            destination.Fields.Add(new DestinationField(destination));
            var func = new ConstantExpression();
            destination.Fields[0].ConnectorIn.Id = connection2.Sink.Id;
            func.ConnectorOut.Id = connection2.Source.Id;

            var objects = new List<IExpressionObjectBase>
                              {   
                                  destination,
                                  func,
                                  connection2
                              };

            var destNode = obj.CreateExpressionNodes(objects);
            Assert.AreEqual(typeof(ConstantNode), destNode.ResultNodes.FirstOrDefault().Expression.GetType());
        }
Exemplo n.º 14
0
 /// <summary>
 /// Adds the field node.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="diagramViewModel">The diagram view model.</param>
 private static void AddFieldNode(ConstantExpression item, IDiagramViewModel diagramViewModel)
 {
     var dfl = new ConstantExpressionNode(diagramViewModel, item);
     diagramViewModel.Items.Add(new NodeViewModel<ConstantExpressionNode, ExpressionConnection>(dfl, diagramViewModel));
 }
Exemplo n.º 15
0
        public void WhenConnectorDataTypeChanges_ExpressionConnectorDataTypeIsUpdated()
        {
            // Arrange.
            var expression = new ConstantExpression { ConnectorOut = { DataType = NodeDataType.String } };
            var expressionConnector = new ExpressionConnector(ConnectorType.Out, expression.ConnectorOut);

            Assert.AreEqual(NodeDataType.String, expressionConnector.DataType);

            // Act.
            expression.ConnectorOut.DataType = NodeDataType.Int;

            // Assert.
            Assert.AreEqual(NodeDataType.Int, expressionConnector.DataType);
        }
        private void UpdateConstantExpression(ConstantExpression expression)
        {
            if (expression.ConnectorOut.DataType != NodeDataType.ProcessState)
                return;

            var stateGuid = expression.Value as Guid?;

            if (ExpressionDesigner.Value.Diagram.StateList.All(s => s.Guid != stateGuid))
            {
                expression.Value = null;
            }
        }
Exemplo n.º 17
0
        private static OneInTwoOutExpression CreateValidExpression()
        {
            var source = new ConstantExpression();
            var destination = new DestinationFieldList();
            var destinationField1 = new DestinationField(destination);
            var destinationField2 = new DestinationField(destination);
            var expression = new OneInTwoOutExpression();
            expression.ConnectorIn.ConnectedTo = source.ConnectorOut;
            expression.Connector1Out.ConnectedTo = destinationField1.ConnectorIn;
            expression.Connector2Out.ConnectedTo = destinationField2.ConnectorIn;

            return expression;
        }
Exemplo n.º 18
0
        public void ValidationMessageTest()
        {
            var source = new ConstantExpression
                             {
                                 ConnectorOut = {Name = "co"}
                             };

            Assert.IsFalse(string.IsNullOrEmpty(source.ValidationMessage));

            source.ConnectorOut.ConnectedTo = new ConnectorIn(null);
            Assert.IsTrue(string.IsNullOrEmpty(source.ValidationMessage));
        }
Exemplo n.º 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConstantDialogViewModel"/> class.
 /// </summary>
 public ConstantDialogViewModel()
 {
     Constant = new ConstantExpression();
     populateChartTypes();
 }
Exemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConstantDialogViewModel"/> class.
 /// </summary>
 /// <param name="constant">The constant.</param>
 public ConstantDialogViewModel(ConstantExpression constant)
 {
     Constant = constant;
     populateChartTypes();
 }
Exemplo n.º 21
0
        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns>ExpressionObjectBase.</returns>
        public override ExpressionObjectBase Clone()
        {
            var clone = new ConstantExpression
                            {
                                ExpressionName = ExpressionName, Value = Value,
                                Width = Width,
                                Height = Height,
                                Top = Top,
                                Left = Left
                            };

            ConnectorOut.Clone(clone.ConnectorOut);

            return clone;
        }
Exemplo n.º 22
0
        public void ValidateTest()
        {
            var source = new ConstantExpression {ConnectorOut = {DataType = NodeDataType.Boolean}, Value = "test"};

            Assert.IsFalse(source.Validate());
            source.Value = true;
            Assert.IsTrue(source.Validate());
            source.Value = "true";
            Assert.IsTrue(source.Validate());

            source.ConnectorOut.DataType = NodeDataType.DateTime;
            source.Value = "test";
            Assert.IsFalse(source.Validate());
            source.Value = DateTime.Now;
            Assert.IsTrue(source.Validate());
            source.Value = "2012-01-01";
            Assert.IsTrue(source.Validate());

            source.ConnectorOut.DataType = NodeDataType.Decimal;
            source.Value = "test";
            Assert.IsFalse(source.Validate());
            source.Value = 100m;
            Assert.IsTrue(source.Validate());
            source.Value = "100";
            Assert.IsTrue(source.Validate());

            source.ConnectorOut.DataType = NodeDataType.Double;
            source.Value = "test";
            Assert.IsFalse(source.Validate());
            source.Value = 100.0;
            Assert.IsTrue(source.Validate());
            source.Value = "100";
            Assert.IsTrue(source.Validate());

            source.ConnectorOut.DataType = NodeDataType.Int;
            source.Value = "test";
            Assert.IsFalse(source.Validate());
            source.Value = 100;
            Assert.IsTrue(source.Validate());
            source.Value = "100";
            Assert.IsTrue(source.Validate());
            source.Value = "100.100";
            Assert.IsFalse(source.Validate());
            source.Value = "100,100";
            Assert.IsFalse(source.Validate());
            source.Value = "9999999999";
            Assert.IsFalse(source.Validate());

            source.ConnectorOut.DataType = NodeDataType.String;
            source.Value = "test";
            Assert.IsTrue(source.Validate());
            source.Value = 100;
            Assert.IsTrue(source.Validate());
            source.Value = "100";
            Assert.IsTrue(source.Validate());

            source.ConnectorOut.DataType = NodeDataType.ChartType;
            source.Value = "test";
            Assert.IsFalse(source.Validate());
            source.Value = "XBarXChart";
            Assert.IsTrue(source.Validate());
            source.Value = "2";
            Assert.IsFalse(source.Validate());

            source.ConnectorOut.DataType = NodeDataType.ChartType;
            source.Value = ChartTypesExEnum.PChart;
            Assert.IsTrue(source.Validate());
        }