Ejemplo 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);
        }
Ejemplo n.º 2
0
        public void  VerifyParentChildReferenceGetValue()
        {
            var dataChild  = SetUpParentChildData("Child", "Grandchild", "Grandchild");
            var dataParent = SetUpParentChildReferenceData("Parent", "Child", "Child", "Child", dataChild);
            var genObject  = GenObject.GetContext(dataParent.Root, "GrandChild");
            var id         = dataParent.GenDataDef.GetId("Parent", "Name");

            Assert.AreEqual("Parent", genObject.GetValue(id));
        }
Ejemplo n.º 3
0
        public void TestObjectContextOfSiblingWithInheritance()
        {
            var dataFile         = GetTestDataFileName("InheritanceDataSaveTest");
            var d                = PopulateInheritanceData(dataFile);
            var container        = GetFirstObject(d);
            var @virtual1        = GetFirstObjectOfSubClass(container, "Abstract");
            var containerContext = GenObject.GetContext(container, "Abstract");

            Assert.AreSame(@virtual1, containerContext);
        }
        public void ContextNoReferencePropertyExistsNoReferenceTest()
        {
            var f = GenDataDef.CreateMinimal();
            var d = new GenDataBase(f);

            SetUpData(d);
            var genObject = GenObject.GetContext(d.Root, "Class");
            var id        = f.GetId("Class.Reference");

            Assert.AreEqual("", genObject.GetValue(id));
        }
Ejemplo n.º 5
0
        protected static void CheckOrder(GenDataBase d1, string order, string action)
        {
            var d  = d1;
            var id = d.GenDataDef.GetId("SubClass.Name");
            var s0 = GenObject.GetContext(d.Root, "SubClass");
            var s1 = GetNextObjectInSubClass(s0);
            var s2 = GetNextObjectInSubClass(s1);

            Assert.AreEqual("SubClass" + order[0], s0.GetValue(id), action + " first item");
            Assert.AreEqual("SubClass" + order[1], s1.GetValue(id), action + " second item");
            Assert.AreEqual("SubClass" + order[2], s2.GetValue(id), action + " third item");
        }
        public void ContextNoFirstPropertyExistsSecondTest()
        {
            var f = GenDataDef.CreateMinimal();
            var d = new GenDataBase(f);

            SetUpData(d);
            CreateGenObject(d.Root, "Class", "Class0");
            var genObject = GetNextObjectInSubClass(GenObject.GetContext(d.Root, "Class"));
            var id        = f.GetId("Class.First");

            Assert.AreEqual("", genObject.GetValue(id));
        }
Ejemplo n.º 7
0
        public void TestObjectContextOfChild()
        {
            var d      = SetUpParentChildData("Parent", "Child", "FirstChild");
            var parent = GetFirstObject(d);
            var child  = GetFirstObjectOfSubClass(parent, "Child");

            var parentContext = GenObject.GetContext(parent, "Child");

            Assert.AreSame(child, parentContext);
            parentContext = GenObject.GetContext(parent, "CHILD"); // Case independent search
            Assert.AreSame(child, parentContext);
        }
Ejemplo n.º 8
0
        public void TestObjectContextOfAReferenceObjectFromParent()
        {
            var dataChild  = SetUpParentChildData("Child", "Grandchild", "Grandchild");
            var dataParent = SetUpParentChildReferenceData("Parent", "Child", "Child", "Child", dataChild);
            var parent     = GetFirstObject(dataParent);
            var grandchild = GetFirstObjectOfSubClass(GetFirstObject(dataChild), "GrandChild");

            Assert.IsNotNull(grandchild);
            var granddhildContext = GenObject.GetContext(parent, "Grandchild");

            Assert.AreSame(grandchild, granddhildContext);
        }
Ejemplo n.º 9
0
        public void ContextWithReferenceTests()
        {
            var dataChild  = SetUpParentChildData("Child", "Grandchild", "Grandchild");
            var dataParent = SetUpParentChildReferenceData("Parent", "Child", "Child", "Child", dataChild);

            for (var i = 1; i < dataParent.GenDataDef.Classes.Count; i++)
            {
                var genObject = GenObject.GetContext(dataParent.Root, dataParent.GenDataDef.Classes[i].Name);
                Assert.IsNotNull(genObject, i + ": " + dataParent.GenDataDef.Classes[i].Name);
                Assert.AreEqual(genObject.ParentSubClass.Definition.SubClass.RefClassId, genObject.ClassId);
            }
        }
        public void ContextEmptyFirstPropertyExistsTest()
        {
            var f = GenDataDef.CreateMinimal();

            f.AddClassInstanceProperty(1, "First");
            var d = new GenDataBase(f);

            SetUpData(d);
            var genObject = GenObject.GetContext(d.Root, "Class");
            var id        = f.GetId("Class.First");

            Assert.AreEqual("", genObject.GetValue(id));
        }
        public void ContextReferencePropertyExistsWithValueTest()
        {
            var f   = GenDataDef.CreateMinimal();
            var idx = f.AddClassInstanceProperty(1, "Reference");
            var d   = new GenDataBase(f);

            SetUpData(d);
            var id        = f.GetId("Class.Reference");
            var genObject = GenObject.GetContext(d.Root, "Class");

            genObject.Attributes[idx] = "Reference value";
            Assert.AreEqual("Reference value", genObject.GetValue(id));
        }
Ejemplo n.º 12
0
        public void VerifySetUpParentChildDataMethod()
        {
            var d = SetUpParentChildData("Parent", "Child", "Child");
            var f = d.GenDataDef;

            Assert.AreEqual(3, f.Classes.Count);
            Assert.AreEqual("Parent", f.GetClassName(1));
            Assert.AreEqual("Child", f.GetClassName(2));
            Assert.AreEqual(1, f.GetClassSubClasses(1).Count);
            Assert.AreEqual(2, f.GetClassSubClasses(1)[0].SubClass.ClassId);
            Assert.AreEqual("", f.GetClassSubClasses(1)[0].Reference);
            Assert.AreEqual("Parent", GenObject.GetContext(d.Root, "Parent").Attributes[0]);
            Assert.AreEqual("Child", GenObject.GetContext(d.Root, "Child").Attributes[0]);
        }
Ejemplo n.º 13
0
        public string GetNodeExpansionText(GenDataBase genData, GenObject genObject)
        {
            GenObject = genObject;
            if (Fragment == null)
            {
                return("");
            }
            var context = GenObject.GetContext(genObject ?? genData.Root, Fragment.ClassName());

            if (context == null)
            {
                return("");
            }
            return(GenFragmentExpander.Expand(genData.GenDataDef, context, Fragment));
        }
Ejemplo n.º 14
0
        public void TestObjectContextOfGrandparent()
        {
            var f = SetUpParentChildDef("Parent", "Child");

            SetUpChildDef("Child", "GrandChild", f);
            var d = new GenDataBase(f)
            {
                DataName = "Parent"
            };
            var parent     = CreateGenObject(d.Root, "Parent", "Parent");
            var child      = CreateGenObject(parent, "Child", "FirstChild");
            var grandChild = CreateGenObject(child, "GrandChild", "FirstGrandchild");

            var grandparentContext = GenObject.GetContext(grandChild, "Parent");

            Assert.AreSame(parent, grandparentContext);
            grandparentContext = GenObject.GetContext(grandChild, "PARENT"); // Case independent search
            Assert.AreSame(parent, grandparentContext);
        }
Ejemplo n.º 15
0
        public void TestObjectContextOfSibling()
        {
            var f = SetUpParentChildDef("Parent", "FirstChild");

            SetUpChildDef("Parent", "SecondChild", f);
            var d = new GenDataBase(f)
            {
                DataName = "Parent"
            };
            var parent      = CreateGenObject(d.Root, "Parent", "Parent");
            var firstChild  = CreateGenObject(parent, "FirstChild", "FirstChild");
            var secondChild = CreateGenObject(parent, "SecondChild", "SecondChild");

            var siblingContext = GenObject.GetContext(firstChild, "SecondChild");

            Assert.AreSame(secondChild, siblingContext);
            siblingContext = GenObject.GetContext(firstChild, "SECONDCHILD"); // Case independent search
            Assert.AreSame(secondChild, siblingContext);
        }
Ejemplo n.º 16
0
        public void VerifyNestedSetUpParentChildReferenceDataMethod()
        {
            var dataGrandchildhild = SetUpParentChildData("Grandchild", "Greatgrandchild", "Greatgrandchild");
            var dataChild          = SetUpParentChildReferenceData("Child", "Grandchild", "Grandchild", "GrandChild", dataGrandchildhild);
            var dataParent         = SetUpParentChildReferenceData("Parent", "Child", "Child", "Child", dataChild);

            Assert.AreEqual(1, dataParent.Root.SubClass.Count);
            Assert.AreEqual(5, dataParent.GenDataDef.Classes.Count);
            var parent = GenObject.GetContext(dataParent.Root, "Parent");

            Assert.AreEqual("Parent", parent.Attributes[0]);
            Assert.That(dataParent.Cache.ContainsKey("child"));
            Assert.AreEqual(1, parent.SubClass.Count);
            var child = GenObject.GetContext(dataParent.Root, "Child");

            Assert.IsNotNull(child);
            Assert.AreEqual(2, dataParent.GetClassId("Child"));
            Assert.AreEqual("Child", child.Attributes[0]);
            var grandchild = GenObject.GetContext(dataParent.Root, "GrandChild");

            Assert.AreEqual(3, dataParent.GetClassId("GrandChild"));
            Assert.AreEqual("Grandchild", grandchild.Attributes[0]);
            Assert.AreEqual(1, grandchild.ParentSubClass.Definition.SubClass.RefClassId); // Check this
        }