Esempio n. 1
0
        public void GenLookupContextTest()
        {
            var d = SetUpLookupContextData();
            var f = d.GenDataDef;
            var r = new GenProfileFragment(new GenProfileParams(GenData.GenDataDef));

            var b  = new GenBlock(new GenFragmentParams(f, r));
            var p0 = new GenPlaceholderFragment(new GenPlaceholderFragmentParams(f, b, f.GetId("Parent.Name")));
            var t0 = new GenTextFragment(new GenTextFragmentParams(f, b, ","));

            b.Body.Add(p0);
            b.Body.Add(t0);

            var g  = new GenLookup(new GenLookupParams(f, b, "Lookup.Name=Child.Lookup"));
            var p1 = new GenPlaceholderFragment(new GenPlaceholderFragmentParams(f, g, f.GetId("Lookup.Name")));
            var t1 = new GenTextFragment(new GenTextFragmentParams(f, g, ","));

            Assert.IsFalse(g.NoMatch);

            b.Body.Add(g);
            g.Body.Add(p1);
            g.Body.Add(t1);

            var parent = GenObject.GetContext(d.Root, "Parent");
            var child  = GetFirstObjectOfSubClass(parent, "Child");

            b.GenObject = child;
            VerifyFragment(d, b, "GenBlock", FragmentType.Block, "Block",
                           "`{`Parent.Name`,`%Lookup.Name=Child.Lookup:`Lookup.Name`,`]`]", "Parent,Valid,", false, null, r.Profile.GenDataBase.GenDataDef);

            child       = GetLastObjectInSubClass(child);
            b.GenObject = child;
            VerifyFragment(d, b, "GenBlock", FragmentType.Block, "Block",
                           "`{`Parent.Name`,`%Lookup.Name=Child.Lookup:`Lookup.Name`,`]`]", "Parent,", false, null, r.Profile.GenDataBase.GenDataDef);
        }
Esempio n. 2
0
        protected static void TestCondition(GenDataBase genData, TestConditionParams testConditionParams)
        {
            var genDataDef = genData.GenDataDef;

            if (testConditionParams.CondOut == "")
            {
                testConditionParams.CondOut = testConditionParams.CondIn;
            }
            if (testConditionParams.ProfileLabel == "")
            {
                testConditionParams.ProfileLabel = testConditionParams.CondIn;
            }

            var          root = new GenProfileFragment(new GenProfileParams(genDataDef));
            const string r    = "Condition holds";
            var          exp  = testConditionParams.Expected ? r : "";

            var c = ProfileFragmentSyntaxDictionary.ActiveProfileFragmentSyntaxDictionary.ParseCondition(genDataDef, testConditionParams.CondIn);
            var g = new GenCondition(new GenConditionParams(genDataDef, root, c));

            g.GenObject = GetFirstObjectOfSubClass(GetLastObjectInSubClass(GetFirstObject(genData)), "Property");
            var t = new GenTextFragment(new GenTextFragmentParams(genDataDef, g, r));

            g.Body.Add(t);
            VerifyFragment(genData, g, "GenCondition", FragmentType.Condition, testConditionParams.ProfileLabel,
                           String.Format("`?{0}:{1}`]", testConditionParams.CondOut, r), exp, false, null, g.Fragment.GenDataBase.GenDataDef);
        }
Esempio n. 3
0
        public void GenLookupMatchTest()
        {
            var d = SetUpLookupData();
            var f = d.GenDataDef;
            var r = new GenProfileFragment(new GenProfileParams(GenData.GenDataDef));

            var g = new GenLookup(new GenLookupParams(f, r, "Class.Name=SubClass.Name"));
            var p = new GenPlaceholderFragment(new GenPlaceholderFragmentParams(f, g, f.GetId("Class.Name")));
            var t = new GenTextFragment(new GenTextFragmentParams(d.GenDataDef, g, ","));

            g.Body.Add(p);
            g.Body.Add(t);
            Assert.IsFalse(g.NoMatch);

            var c = GetLastObjectInSubClass(GetFirstObject(d)); // Has no subclasses
            var s = GetFirstObjectOfSubClass(c, "SubClass");

            g.GenObject = s;
            VerifyFragment(d, g, "GenLookup", FragmentType.Lookup, "Class.Name=SubClass.Name",
                           "`%Class.Name=SubClass.Name:`Class.Name`,`]", "", false, null, r.Profile.GenDataBase.GenDataDef);

            c           = GetFirstObject(d); // Has subclasses
            s           = GetFirstObjectOfSubClass(c, "SubClass");
            g.GenObject = s;                 //d.Context[SubClassClassId].GenObject;
            VerifyFragment(d, g, "GenLookup", FragmentType.Lookup, "Class.Name=SubClass.Name",
                           "`%Class.Name=SubClass.Name:`Class.Name`,`]", "SubClass,", false, null, r.Profile.GenDataBase.GenDataDef);
        }
Esempio n. 4
0
        public void GenTextFragmentTest()
        {
            var r = new GenProfileFragment(new GenProfileParams(GenData.GenDataDef));
            var g = new GenTextFragment(new GenTextFragmentParams(GenDataDef, r, "Text fragment"));

            VerifyFragment(GenData, g, "GenTextFragment", FragmentType.Text, "Text", "Text fragment", "Text fragment",
                           true, null, r.Profile.GenDataBase.GenDataDef);
        }
Esempio n. 5
0
        public static GenProfileFragment CreateProfile(GenDataDef genDataDef)
        {
            var def = new StringBuilder();

            def.Append("Definition=");
            def.AppendLine(genDataDef.DefinitionName);
            var profile = new GenProfileFragment(new GenProfileParams(genDataDef));
            var defText = new GenTextFragment(new GenTextFragmentParams(genDataDef, profile, ""));

            profile.Body.Add(defText);

            ClassDefinition(genDataDef, 0, def);
            ClassProfile(genDataDef, 0, profile, profile);
            defText.Text = def + ".\r\n";
            return(profile);
        }
Esempio n. 6
0
        public void GenAnnotationTest()
        {
            var r = new GenProfileFragment(new GenProfileParams(GenData.GenDataDef));

            var g = new GenAnnotation(new GenFragmentParams(GenDataDef, r));

            r.Body.Add(g);
            var p =
                new GenPlaceholderFragment(new GenPlaceholderFragmentParams(GenDataDef, g,
                                                                            GenDataDef.GetId("Property.Name")));
            var t = new GenTextFragment(new GenTextFragmentParams(GenData.GenDataDef, g, ","));

            g.Body.Add(p);
            g.Body.Add(t);
            VerifyFragment(GenData, g, "GenAnnotation", FragmentType.Annotation, "Annotation", "`-`Property.Name`,`]", "", false, null, r.Profile.GenDataBase.GenDataDef);
        }
Esempio n. 7
0
        public void GenBlockTest()
        {
            var r = new GenProfileFragment(new GenProfileParams(GenData.GenDataDef));

            var g = new GenBlock(new GenFragmentParams(GenDataDef, r));

            r.Body.Add(g);
            var p =
                new GenPlaceholderFragment(new GenPlaceholderFragmentParams(GenDataDef, g,
                                                                            GenDataDef.GetId("Property.Name")));
            var t = new GenTextFragment(new GenTextFragmentParams(GenData.GenDataDef, g, ","));

            g.Body.Add(p);
            g.Body.Add(t);
            g.GenObject = GetNextObjectInSubClass(GetFirstObjectOfSubClass(GetFirstObject(GenData), "Property"));
            VerifyFragment(GenData, g, "GenBlock", FragmentType.Block, "Block", "`{`Property.Name`,`]", "Property2,", false, null, r.Profile.GenDataBase.GenDataDef);
        }
Esempio n. 8
0
        private static void SetFunctionParameter(GenDataBase genData, GenFunction genFunction, string value)
        {
            var p0 = new GenTextFragment(new GenTextFragmentParams(genData.GenDataDef, genFunction, value));

            genFunction.Body.Add(p0);
        }