Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of <see cref="SourceFieldNode"/> class.
 /// </summary>
 /// <param name="dataType">The type of the constant defined by the current node.</param>
 /// <param name="fieldName">Name of the field.</param>
 /// <param name="value">The constant value.</param>
 /// <param name="setName">The name of the set of data to which this node belongs</param>
 /// <param name="propertyPath">The property path.</param>
 /// <param name="systemName">Name of the system.</param>
 /// <param name="objectName">Name of the object.</param>
 /// <param name="parentNode">The parent node.</param>
 public SourceFieldNode(NodeDataType dataType, string fieldName, object value, string setName, string propertyPath, string systemName = null, string objectName = null, SourceFieldNode parentNode = null, bool isGroupingField = false) : this(dataType)
 {
     InitialFieldName = fieldName;
     FieldName = DefineFieldName(fieldName, systemName);
     Value = value;
     PropertyPath = propertyPath;
     SetName = setName;
     ParentNode = parentNode;
     ObjectName = objectName;
     IsGroupingField = isGroupingField;
 }
Ejemplo n.º 2
0
        public void TestProperties()
        {
            var obj = new SourceFieldNode(NodeDataType.GageRR, "Field Name", null, SourceFieldSetNames.Item, "FIeldName");
            TestsHelper.TestPublicPropertiesGetSet(obj, x => x.IsGroupingField);

            //IsGroupingField has private setter
            var isGroupingFieldProperty = typeof (SourceFieldNode).GetProperty("IsGroupingField");
            Assert.IsNotNull(isGroupingFieldProperty);
            var accessors = isGroupingFieldProperty.GetAccessors(false);
            Assert.AreEqual(1, accessors.Length);
            Assert.AreEqual("get_IsGroupingField", accessors[0].Name);
        }
Ejemplo n.º 3
0
        public void TestConstructor_IsGroupingFalse()
        {
            var node = new SourceFieldNode(NodeDataType.GageRR, "Field Name", null, SourceFieldSetNames.Item, "FIeldName");

            Assert.AreEqual("Field Name", node.InitialFieldName);
            Assert.AreEqual("Field Name",node.FieldName);
            Assert.IsNull(node.Value);
            Assert.AreEqual("FIeldName", node.PropertyPath);
            Assert.AreEqual(SourceFieldSetNames.Item, node.SetName);
            Assert.IsNull(node.ParentNode);
            Assert.IsNull(node.ObjectName);
            Assert.IsFalse(node.IsGroupingField);
        }
Ejemplo n.º 4
0
        public void SourceFieldNodeVisitTest()
        {
            var node = new SourceFieldNode(NodeDataType.String);
            var visitor = Mock.Create<INodeVisitor>();
            Mock.Arrange(() => visitor.Visit(node)).MustBeCalled();

            node.AcceptVisitor(visitor);
        }
Ejemplo n.º 5
0
 public void SourceFieldNodeGetFullPathShouldReturnJustFieldNameIfDoesNotHasParentTest()
 {
     var node = new SourceFieldNode(NodeDataType.String, "Field", "Value", "Set", "PropertyPath");
     Assert.AreEqual("Field", node.GetFullPath());
 }
Ejemplo n.º 6
0
 public void SourceFieldNodeGetFullPathShouldReturnParentNodeNameIfHasParentTest()
 {
     var node = new SourceFieldNode(NodeDataType.String, "Field", "Value", "Set", "PropertyPath", "SystemName", "ObjectName", new SourceFieldNode(NodeDataType.String, "ParentField", "Value", "Set", "PropertyPath"));
     Assert.AreEqual("ParentField.SystemName", node.GetFullPath());
 }
Ejemplo n.º 7
0
        public void SourceFieldNodeCtorTest()
        {
            Assert.AreEqual(ExpressionNodeType.SourceField, new SourceFieldNode(NodeDataType.String).NodeType);
           
            var node = new SourceFieldNode(NodeDataType.String, "Field", "Value", "Set", "PropertyPath", "SystemName", "ObjectName", new SourceFieldNode(NodeDataType.Field));
            Assert.AreEqual("SystemName", node.FieldName);
            Assert.AreEqual(NodeDataType.String, node.DataType);
            Assert.AreEqual("Value", node.Value);
            Assert.AreEqual("Set", node.SetName);
            Assert.AreEqual("PropertyPath", node.PropertyPath);
            Assert.AreEqual("Field", node.InitialFieldName);
            Assert.AreEqual("ObjectName", node.ObjectName);
            Assert.IsNotNull(node.ParentNode);

            node = new SourceFieldNode(NodeDataType.String, "Field", "Value", "Set", "PropertyPath");
            Assert.AreEqual("Field", node.FieldName);
        }
Ejemplo n.º 8
0
        public void TestConstructor_IsGroupingTrue()
        {
            var node = new SourceFieldNode(NodeDataType.GageRR, "Field Name", null, SourceFieldSetNames.Item, "FIeldName", isGroupingField: true);

            Assert.IsTrue(node.IsGroupingField);
        }
        private string GetSourceFieldName(SourceFieldNode field)
        {
            if (field.SetName == SourceFieldSetNames.CurrentUserInfo)
            {
                return field.FieldName.Substring("Utils.CurrentUser".Length);
            }

            if (field.SetName == SourceFieldSetNames.SystemParametersItem)
            {
                var match = _sysParamRegex.Match(field.FieldName);
                if (match.Groups.Count > 0)
                {
                    return match.Groups[1].Value;
                }
            }

            return field.FieldName;
        }