コード例 #1
0
        public void TestConnectorSerialization()
        {
            var obj = new FiveInOneOutExpression();

            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 FiveInOneOutExpression();
                result.Deserialize(wr);

                Assert.AreEqual(obj.Id, result.Id);
                Assert.AreEqual(obj.Connector1In.Id, result.Connector1In.Id);
                Assert.AreEqual(obj.Connector2In.Id, result.Connector2In.Id);
                Assert.AreEqual(obj.Connector3In.Id, result.Connector3In.Id);
                Assert.AreEqual(obj.Connector4In.Id, result.Connector4In.Id);
                Assert.AreEqual(obj.Connector5In.Id, result.Connector5In.Id);
                Assert.AreEqual(obj.ConnectorOut.Id, result.ConnectorOut.Id);
            }
        }
コード例 #2
0
        public void TestConnectorProperties()
        {
            var obj = new FiveInOneOutExpression();
            TestsHelper.TestPublicPropertiesGetSet(new FiveInOneOutExpression());

            Assert.IsNotNull(obj.Connector1In);
            Assert.IsNotNull(obj.Connector2In);
            Assert.IsNotNull(obj.Connector3In);
            Assert.IsNotNull(obj.Connector4In);
            Assert.IsNotNull(obj.Connector5In);
            Assert.IsNotNull(obj.ConnectorOut);
        }
コード例 #3
0
        public void CloneTest()
        {
            var source = new FiveInOneOutExpression();
            source.ExpressionName = "source";
            source.FunctionName = "func";
            source.Width = 1;
            source.Height = 2;
            source.Top = 3;
            source.Left = 4;
            source.Connector1In.Name = "1";
            source.Connector2In.Name = "2";
            source.Connector3In.Name = "3";
            source.Connector4In.Name = "4";
            source.Connector4In.Name = "5";
            source.ConnectorOut.Name = "6";

            var cloneTo = (FiveInOneOutExpression)source.Clone();
            Assert.AreEqual(source.ExpressionName, cloneTo.ExpressionName);
            Assert.AreEqual(source.FunctionName, cloneTo.FunctionName);
            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.Connector1In.Id, cloneTo.Connector1In.Id);
            Assert.AreNotEqual(source.Connector2In.Id, cloneTo.Connector2In.Id);
            Assert.AreNotEqual(source.Connector3In.Id, cloneTo.Connector3In.Id);
            Assert.AreNotEqual(source.Connector4In.Id, cloneTo.Connector4In.Id);
            Assert.AreNotEqual(source.Connector5In.Id, cloneTo.Connector5In.Id);
            Assert.AreNotEqual(source.ConnectorOut.Id, cloneTo.ConnectorOut.Id);

            Assert.AreEqual(source.Connector1In.Name, cloneTo.Connector1In.Name);
            Assert.AreEqual(source.Connector2In.Name, cloneTo.Connector2In.Name);
            Assert.AreEqual(source.Connector3In.Name, cloneTo.Connector3In.Name);
            Assert.AreEqual(source.Connector4In.Name, cloneTo.Connector4In.Name);
            Assert.AreEqual(source.Connector5In.Name, cloneTo.Connector5In.Name);
            Assert.AreEqual(source.ConnectorOut.Name, cloneTo.ConnectorOut.Name);
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FiveInOneOutExpressionNode"/> class.
        /// </summary>
        /// <param name="diagramViewModel">The diagram view model.</param>
        /// <param name="expressionObject">The expression object.</param>
        /// <exception cref="System.ArgumentNullException">expressionObject</exception>
        public FiveInOneOutExpressionNode(IDiagramViewModel diagramViewModel, FiveInOneOutExpression expressionObject)
            : base(expressionObject)
        {
            if (expressionObject == null) throw new ArgumentNullException("expressionObject");

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

            Connector1In = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.In, expressionObject.Connector1In), _diagramViewModel);
            Connector2In = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.In, expressionObject.Connector2In), _diagramViewModel);
            Connector3In = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.In, expressionObject.Connector3In), _diagramViewModel);
            Connector4In = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.In, expressionObject.Connector4In), _diagramViewModel);
            Connector5In = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.In, expressionObject.Connector5In), _diagramViewModel);
            ConnectorOut = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.Out, expressionObject.ConnectorOut), _diagramViewModel);
        }
コード例 #5
0
        public void GetConnectorsTest()
        {
            var source = new FiveInOneOutExpression
                             {
                                 Connector1In = {Name = "1"},
                                 Connector2In = {Name = "2"},
                                 Connector3In = {Name = "3"},
                                 Connector4In = {Name = "4"},
                                 Connector5In = {Name = "5"},
                                 ConnectorOut = {Name = "6"}
                             };

            var conn = source.GetConnectors();
            var connectors = conn as IList<IConnector> ?? conn.ToList();
            Assert.IsTrue(connectors.Any(x => x.Name == "1"));
            Assert.IsTrue(connectors.Any(x => x.Name == "2"));
            Assert.IsTrue(connectors.Any(x => x.Name == "3"));
            Assert.IsTrue(connectors.Any(x => x.Name == "4"));
            Assert.IsTrue(connectors.Any(x => x.Name == "5"));
            Assert.IsTrue(connectors.Any(x => x.Name == "6"));
        }
コード例 #6
0
        public void DoesInherit_IExpressionProcessor()
        {
            var stub = new FiveInOneOutExpression();

            Assert.IsNotNull(stub as IExpressionProcessor);
        }
コード例 #7
0
        public void ValidationMessageTest()
        {
            var source = new FiveInOneOutExpression
                             {
                                 Connector1In = {Name = "c1"},
                                 Connector2In = {Name = "c2"},
                                 Connector3In = {Name = "c3"},
                                 Connector4In = {Name = "c4"},
                                 Connector5In = {Name = "c5"},
                                 ConnectorOut = {Name = "co"}
                             };

            Assert.IsTrue(source.ValidationMessage.Contains("c1"));
            Assert.IsTrue(source.ValidationMessage.Contains("c2"));
            Assert.IsTrue(source.ValidationMessage.Contains("c3"));
            Assert.IsTrue(source.ValidationMessage.Contains("c4"));
            Assert.IsTrue(source.ValidationMessage.Contains("c5"));
            Assert.IsTrue(source.ValidationMessage.Contains("Result"));

            source.Connector1In.ConnectedTo = new ConnectorOut(null);
            Assert.IsFalse(source.ValidationMessage.Contains("c1"));
            Assert.IsTrue(source.ValidationMessage.Contains("c2"));
            Assert.IsTrue(source.ValidationMessage.Contains("c3"));
            Assert.IsTrue(source.ValidationMessage.Contains("c4"));
            Assert.IsTrue(source.ValidationMessage.Contains("c5"));
            Assert.IsTrue(source.ValidationMessage.Contains("Result"));

            source.Connector2In.ConnectedTo = new ConnectorOut(null);
            Assert.IsFalse(source.ValidationMessage.Contains("c1"));
            Assert.IsFalse(source.ValidationMessage.Contains("c2"));
            Assert.IsTrue(source.ValidationMessage.Contains("c3"));
            Assert.IsTrue(source.ValidationMessage.Contains("c4"));
            Assert.IsTrue(source.ValidationMessage.Contains("c5"));
            Assert.IsTrue(source.ValidationMessage.Contains("Result"));

            source.Connector3In.ConnectedTo = new ConnectorOut(null);
            Assert.IsFalse(source.ValidationMessage.Contains("c1"));
            Assert.IsFalse(source.ValidationMessage.Contains("c2"));
            Assert.IsFalse(source.ValidationMessage.Contains("c3"));
            Assert.IsTrue(source.ValidationMessage.Contains("c4"));
            Assert.IsTrue(source.ValidationMessage.Contains("c5"));
            Assert.IsTrue(source.ValidationMessage.Contains("Result"));

            source.Connector4In.ConnectedTo = new ConnectorOut(null);
            Assert.IsFalse(source.ValidationMessage.Contains("c1"));
            Assert.IsFalse(source.ValidationMessage.Contains("c2"));
            Assert.IsFalse(source.ValidationMessage.Contains("c3"));
            Assert.IsFalse(source.ValidationMessage.Contains("c4"));
            Assert.IsTrue(source.ValidationMessage.Contains("c5"));
            Assert.IsTrue(source.ValidationMessage.Contains("Result"));

            source.Connector5In.ConnectedTo = new ConnectorOut(null);
            Assert.IsFalse(source.ValidationMessage.Contains("c1"));
            Assert.IsFalse(source.ValidationMessage.Contains("c2"));
            Assert.IsFalse(source.ValidationMessage.Contains("c3"));
            Assert.IsFalse(source.ValidationMessage.Contains("c4"));
            Assert.IsFalse(source.ValidationMessage.Contains("c5"));
            Assert.IsTrue(source.ValidationMessage.Contains("Result"));

            source.ConnectorOut.ConnectedTo = new ConnectorIn(null);
            Assert.IsTrue(string.IsNullOrEmpty(source.ValidationMessage));
        }
コード例 #8
0
        public void IsValidTest()
        {
            var source = new FiveInOneOutExpression();

            Assert.IsFalse(source.IsValid);
            
            source.Connector1In.ConnectedTo = new ConnectorOut(null);
            Assert.IsFalse(source.IsValid);

            source.Connector2In.ConnectedTo = new ConnectorOut(null);
            Assert.IsFalse(source.IsValid);

            source.Connector3In.ConnectedTo = new ConnectorOut(null);
            Assert.IsFalse(source.IsValid);

            source.Connector4In.ConnectedTo = new ConnectorOut(null);
            Assert.IsFalse(source.IsValid);

            source.Connector5In.ConnectedTo = new ConnectorOut(null);
            Assert.IsFalse(source.IsValid);

            source.ConnectorOut.ConnectedTo = new ConnectorIn(null);
            Assert.IsTrue(source.IsValid);
        }
コード例 #9
0
        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns>ExpressionObjectBase.</returns>
        public override ExpressionObjectBase Clone()
        {
            var clone = new FiveInOneOutExpression(Type)
                            {
                                ExpressionName = ExpressionName, FunctionName = FunctionName,
                                Width = Width, Height = Height, Top = Top, Left = Left,
                            };
            Connector1In.Clone(clone.Connector1In);
            Connector2In.Clone(clone.Connector2In);
            Connector3In.Clone(clone.Connector3In);
            Connector4In.Clone(clone.Connector4In);
            Connector5In.Clone(clone.Connector5In);
            ConnectorOut.Clone(clone.ConnectorOut);

            return clone;
        }
コード例 #10
0
 /// <summary>
 /// Determines whether [is valid mapping] [the specified expression].
 /// </summary>
 /// <param name="expression">The expression.</param>
 /// <param name="sourceContext">The source context.</param>
 /// <returns><c>true</c> if [is valid mapping] [the specified expression]; otherwise, <c>false</c>.</returns>
 private bool IsValidMapping(FiveInOneOutExpression expression, SourceField sourceContext)
 {
     return expression.Connector1In != null && IsValidMapping(expression.Connector1In, sourceContext) &&
            expression.Connector2In != null && IsValidMapping(expression.Connector2In, sourceContext) &&
            expression.Connector3In != null && IsValidMapping(expression.Connector3In, sourceContext) &&
            expression.Connector4In != null && IsValidMapping(expression.Connector4In, sourceContext) &&
            expression.Connector5In != null && IsValidMapping(expression.Connector5In, sourceContext);
 }
コード例 #11
0
        private void ToExpressionNodeFiveInOneOutFunctionTest(ExpressionNodeType nodeType, Type functionNode)
        {
            var obj = new ExpressionNodeFactory();
            var connection1 = new Connection();
            connection1.Source = new ConnectorOut(connection1);
            connection1.Sink = new ConnectorIn(connection1);

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

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

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

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

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

            var destination = new DestinationFieldList { UniqueName = "Destination" };
            destination.Fields.Add(new DestinationField(destination));
            var source = new SourceFieldList();
            source.Fields.Add(new SourceField(source) { Name = "Field" });
            source.Fields.Add(new SourceField(source) { Name = "Field" });
            source.Fields.Add(new SourceField(source) { Name = "Field" });
            source.Fields.Add(new SourceField(source) { Name = "Field" });
            source.Fields.Add(new SourceField(source) { Name = "Field" });

            var func = new FiveInOneOutExpression(nodeType) { UniqueName = "Function" };

            func.Connector1In.Id = connection1.Sink.Id;
            source.Fields[0].ConnectorOut.Id = connection1.Source.Id;
            func.Connector2In.Id = connection2.Sink.Id;
            source.Fields[1].ConnectorOut.Id = connection2.Source.Id;
            func.Connector3In.Id = connection3.Sink.Id;
            source.Fields[2].ConnectorOut.Id = connection3.Source.Id;
            func.Connector4In.Id = connection4.Sink.Id;
            source.Fields[3].ConnectorOut.Id = connection4.Source.Id;
            func.Connector5In.Id = connection5.Sink.Id;
            source.Fields[4].ConnectorOut.Id = connection5.Source.Id;

            destination.Fields[0].ConnectorIn.Id = connection6.Sink.Id;
            func.ConnectorOut.Id = connection6.Source.Id;

            var objects = new List<IExpressionObjectBase>
                              {   
                                  source,
                                  destination,
                                  func,
                                  connection1,
                                  connection2,
                                  connection3,
                                  connection4,
                                  connection5,
                                  connection6
                              };

            var destNode = obj.CreateExpressionNodes(objects);
            Assert.AreEqual(functionNode, destNode.ResultNodes.FirstOrDefault().Expression.GetType());
        }
コード例 #12
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(FiveInOneOutExpression item, IDiagramViewModel diagramViewModel)
 {
     var node = new FiveInOneOutExpressionNode(diagramViewModel, item);
     diagramViewModel.Items.Add(new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>(node, diagramViewModel));
 }