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); }
public void CreateDestinationNodeShouldThrowExceptionIfHasInvalidItems() { var obj = new ExpressionNodeFactory(); var objects = new List<IExpressionObjectBase> { new FunctionExpression() }; obj.CreateDestinationNode(objects, "Node"); }
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")); }
private void ToExpressionNodeThreeInOneOutFunctionTest(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 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" }); var func = new ThreeInOneOutExpression(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; destination.Fields[0].ConnectorIn.Id = connection4.Sink.Id; func.ConnectorOut.Id = connection4.Source.Id; var objects = new List<IExpressionObjectBase> { source, destination, func, connection1, connection2, connection3, connection4 }; var destNode = obj.CreateExpressionNodes(objects); Assert.AreEqual(functionNode, destNode.ResultNodes.FirstOrDefault().Expression.GetType()); }
public void ToExpressionNode_SetChecklistData_Test() { // Arrange. var nodeFactory = 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 destination = new DestinationFieldList { UniqueName = "Destination" }; destination.Fields.Add(new DestinationField(destination)); destination.Fields.Add(new DestinationField(destination)); var source = new SourceFieldList(); source.Fields.Add(new SourceField(source) { Name = "Field" }); var func = new SetChecklistDataExpression { UniqueName = "Function" }; func.ConnectorIn.Id = connection1.Sink.Id; source.Fields[0].ConnectorOut.Id = connection1.Source.Id; destination.Fields[0].ConnectorIn.Id = connection2.Sink.Id; func.Connector1Out.Id = connection2.Source.Id; destination.Fields[1].ConnectorIn.Id = connection3.Sink.Id; func.Connector2Out.Id = connection3.Source.Id; var objects = new List<IExpressionObjectBase> { source, destination, func, connection1, connection2, connection3 }; // Act. var destNode = nodeFactory.CreateExpressionNodes(objects); // Assert. Assert.IsTrue(destNode.ResultNodes.ElementAt(0).Expression is SetChecklistDataFunctionNode); Assert.IsTrue(destNode.ResultNodes.ElementAt(1).Expression is GetContextValueFunctionNode); }
public void GetSourceExpressionNodeMethodTest() { var obj = new ExpressionNodeFactory(); var privateAccessor = new PrivateAccessor(obj); var sourceField = new SourceField(new Connection(), true) { DataType = NodeDataType.GageRR, Name = "FieldName", SetName = SourceFieldSetNames.Item, InnerName = "FieldName", SystemName = "FieldSystemName", ObjectName = "FieldName", ParentField = null }; var result = privateAccessor.CallMethod("GetSourceExpressionNode", sourceField, null) as SourceFieldNode; Assert.IsNotNull(result); Assert.AreEqual(NodeDataType.GageRR, result.DataType); Assert.AreEqual("FieldName", result.InitialFieldName); Assert.AreEqual("FieldSystemName", result.FieldName); Assert.IsNull(result.Value); Assert.AreEqual("FieldName", result.PropertyPath); Assert.AreEqual(SourceFieldSetNames.Item, result.SetName); Assert.IsNull(result.ParentNode); Assert.AreEqual("FieldName", result.ObjectName); Assert.IsTrue(result.IsGroupingField); }
public void CreateExpressionNodesShouldReturnNullIfDestinationNodeIsMissing() { var obj = new ExpressionNodeFactory(); Assert.IsNull(obj.CreateExpressionNodes(new Collection<IExpressionObjectBase>())); }
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()); }
public void CheckMultipleDestinationsInAddDestinationNode() { 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 destination = new DestinationFieldList { UniqueName = "Destination" }; destination.Fields.Add(new DestinationField(destination) { SystemName = "Field" }); destination.Fields[0].Subfields.Add(new DestinationField(destination) { SystemName = "Subfield", ParentField = destination.Fields[0] }); var source = new SourceFieldList(); source.Fields.Add(new SourceField(source) { Name = "Field" }); var func = new OneInOneOutExpression(ExpressionNodeType.Count) { UniqueName = "Function" }; func.ConnectorIn.Id = connection1.Sink.Id; source.Fields[0].ConnectorOut.Id = connection1.Source.Id; ((DestinationField)destination.Fields[0].Subfields[0]).ConnectorIn.Id = connection2.Sink.Id; func.ConnectorOut.Id = connection2.Source.Id; var objects = new List<IExpressionObjectBase> { source, destination, func, connection1, connection2 }; var destNode = obj.CreateExpressionNodes(objects); Assert.AreEqual("Field.Subfield", destNode.ResultNodes.ToArray()[0].FieldName); }
public void CustomFunctionNodeTest() { 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 FunctionExpression { FunctionName = "Function" }; destination.Fields[0].ConnectorIn.Id = connection.Sink.Id; source.ConnectorOut.Id = connection.Source.Id; var objects = new List<IExpressionObjectBase> { source, destination, connection }; var destNode = obj.CreateExpressionNodes(objects); var sourceNode = destNode.ResultNodes.FirstOrDefault().Expression as CustomFunctionNode; Assert.AreEqual("Function", sourceNode.FunctionName); }
public void ToSourceExpressionNodeShouldReturnFieldWithValue() { 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 SourceFieldList(); source.Fields.Add(new SourceField(source) { Name = "Field" }); destination.Fields[0].ConnectorIn.Id = connection.Sink.Id; source.Fields[0].ConnectorOut.Id = connection.Source.Id; var objects = new List<IExpressionObjectBase> { source, destination, connection }; var destNode = obj.CreateExpressionNodes(objects, new Dictionary<string, object> { { "Field", "Value" } }); var sourceNode = destNode.ResultNodes.FirstOrDefault().Expression as SourceFieldNode; Assert.AreEqual("Field", sourceNode.FieldName); Assert.AreEqual("Value", sourceNode.Value); }
public void ToSourceExpressionNodeShouldThrowExceptionIdSourceFieldListIsInvalid() { 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 SourceFieldList(); source.Fields.Add(new SourceField(source) { Name = "Field" }); destination.Fields[0].ConnectorIn.Id = connection.Sink.Id; source.Fields[0].ConnectorOut.Id = connection.Source.Id; Mock.Arrange(() => source.IsValid).Returns(true).InSequence().Returns(true).InSequence().Returns(false).InSequence(); var objects = new List<IExpressionObjectBase> { source, destination, connection }; obj.CreateExpressionNodes(objects); }