Пример #1
0
        protected static void VerifyFragment(GenDataBase genData, GenFragment genFragment, string expectedClass, FragmentType expectedType, string profileLabel, string profileText, string expected, bool isText, string parentClassName, GenDataDef profileDataDef)
        {
            Assert.AreEqual(expectedClass, genFragment.GetType().Name, "Fragment Class");
            Assert.AreEqual(expectedType, genFragment.Fragment.FragmentType, "Fragment Fragment Type");
            Assert.AreEqual(expectedType, genFragment.FragmentType, "Fragment Type");
            Assert.AreEqual(isText, genFragment.IsTextFragment, "Is text fragment?");
            if (genFragment.GenObject == null)
            {
                genFragment.GenObject = GetFirstObjectOfSubClass(GetFirstObject(genData), "Property");
            }
            var fragment = genFragment.Fragment;

            Assert.AreEqual(expected, GenFragmentExpander.Expand(genData.GenDataDef, genFragment.GenObject, fragment), "Expanded fragment");
            var genFragmentLabel = new GenFragmentLabel(fragment);

            Assert.AreEqual(profileLabel, genFragmentLabel.ProfileLabel(), "Profile label");
            Assert.AreEqual(profileText, genFragment.ProfileText(ProfileFragmentSyntaxDictionary.ActiveProfileFragmentSyntaxDictionary), "Profile text");
            if (parentClassName != null)
            {
                Assert.AreEqual(parentClassName, genFragment.Fragment.ClassName(), "Parent Class ID");
            }
            var str = GenerateFragment(genData, genFragment);

            Assert.AreEqual(expected, str);
            var genDataDef = genData.GenDataDef;

            ValidateFragmentData(genDataDef, parentClassName, genFragment, profileDataDef);
        }
Пример #2
0
        private TreeNode CreateFragmentTree(Fragment genFragment)
        {
            var genFragmentLabel = new GenFragmentLabel(genFragment);
            var item             = CreateTreeNode((int)genFragment.FragmentType, genFragmentLabel.ProfileLabel(), null, genFragment);

            if (genFragment is ContainerFragment && !(genFragment is Function))
            {
                CreateBodyChildTrees(item.Nodes, ((ContainerFragment)genFragment).Body());
            }
            return(item);
        }
Пример #3
0
        public void GenLookupNoMatchTest()
        {
            const string txt     = "SubClass does not exist";
            const string profile = "`[Class:`[SubClass:`%Class.Name=SubClass.Name:`;" + txt + "`]`]`]";
            var          d       = SetUpLookupData();
            var          f       = d.GenDataDef;
            var          p       = new GenCompactProfileParser(f, "", profile);

            var g = ((GenSegment)((GenSegment)p.Body.Fragment[0]).Body.Fragment[0]).Body.Fragment[0];

            Assert.AreEqual(FragmentType.Lookup, g.FragmentType);
            Assert.IsFalse(g.IsTextFragment);
            var genFragmentLabel = new GenFragmentLabel(g.Fragment);

            Assert.AreEqual("~Class.Name=SubClass.Name", genFragmentLabel.ProfileLabel());
            Assert.AreEqual("`%Class.Name=SubClass.Name:`;" + txt + "`]",
                            g.ProfileText(ProfileFragmentSyntaxDictionary.ActiveProfileFragmentSyntaxDictionary));

            var c = GetLastObjectInSubClass(GetFirstObject(d)); // Has no subclasses

            Assert.AreEqual("Property", c.Attributes[0]);
            var s = GetFirstObjectOfSubClass(c, "SubClass");

            g.ParentContainer.GenObject = c;
            g.GenObject = s;
            Assert.AreEqual(txt, GenFragmentExpander.Expand(d.GenDataDef, g.GenObject, g.Fragment));
            var str = GenerateFragment(d, g);

            Assert.AreEqual(txt, str);

            c = GetFirstObject(d);
            Assert.AreEqual("Class", c.Attributes[0]);
            s = GetFirstObjectOfSubClass(c, "SubClass");
            Assert.AreEqual("SubClass", s.Attributes[0]);
            g.GenObject = s;
            str         = GenerateFragment(d, g);
            Assert.AreEqual("", str);
        }