Ejemplo n.º 1
0
        public void MakeNewObjectTest_OwnedObjectSequence()
        {
            int hvoOwner = SilDataAccess.MakeNewObject(1, 0, -1, 0);
            var clid     = SilDataAccess.MetaDataCache.GetClassId("ClassB");
            var flid     = SilDataAccess.MetaDataCache.GetFieldId2(1, "SequenceProp98", false);

            int[] hvoNewObjects = new int[5];
            hvoNewObjects[0] = SilDataAccess.MakeNewObject(clid, hvoOwner, flid, 1);
            hvoNewObjects[2] = SilDataAccess.MakeNewObject(clid, hvoOwner, flid, 1);
            hvoNewObjects[1] = SilDataAccess.MakeNewObject(clid, hvoOwner, flid, 1);
            hvoNewObjects[3] = SilDataAccess.MakeNewObject(clid, hvoOwner, flid, 10);
            hvoNewObjects[4] = SilDataAccess.MakeNewObject(clid, hvoOwner, flid, 0);
            Assert.AreEqual(5, SilDataAccess.get_VecSize(hvoOwner, flid));
            int prevOwnOrd = -1;

            for (int i = 0; i < 5; i++)
            {
                int hvoNew = SilDataAccess.get_VecItem(hvoOwner, flid, i);
                Assert.IsTrue(SilDataAccess.get_IsValidObject(hvoNew));
                Assert.AreEqual(flid, SilDataAccess.get_ObjectProp(hvoNew, (int)CmObjectFields.kflidCmObject_OwnFlid));
                Assert.AreEqual(hvoOwner, SilDataAccess.get_ObjectProp(hvoNew, (int)CmObjectFields.kflidCmObject_Owner));
                int ownOrd = SilDataAccess.get_ObjectProp(hvoNew, (int)CmObjectFields.kflidCmObject_OwnOrd);
                Assert.IsTrue(prevOwnOrd < ownOrd);
                prevOwnOrd = ownOrd;
                Assert.AreEqual(clid, SilDataAccess.get_ObjectProp(hvoNew, (int)CmObjectFields.kflidCmObject_Class));
            }
        }
Ejemplo n.º 2
0
        public void MakeNewObjectTest_OwnedObjectCollection()
        {
            int hvoOwner = SilDataAccess.MakeNewObject(1, 0, -1, 0);
            var clid     = SilDataAccess.MetaDataCache.GetClassId("ClassC");
            var flid     = SilDataAccess.MetaDataCache.GetFieldId2(1, "CollectionProp99", false);
            int hvoNew   = SilDataAccess.MakeNewObject(clid, hvoOwner, flid, -1);

            Assert.IsTrue(SilDataAccess.get_IsValidObject(hvoNew));
            Assert.AreEqual(flid, SilDataAccess.get_ObjectProp(hvoNew, (int)CmObjectFields.kflidCmObject_OwnFlid));
            Assert.AreEqual(hvoOwner, SilDataAccess.get_ObjectProp(hvoNew, (int)CmObjectFields.kflidCmObject_Owner));
            Assert.AreEqual(clid, SilDataAccess.get_ObjectProp(hvoNew, (int)CmObjectFields.kflidCmObject_Class));
            Assert.AreEqual(1, SilDataAccess.get_VecSize(hvoOwner, flid));
            Assert.AreEqual(hvoNew, SilDataAccess.get_VecItem(hvoOwner, flid, 0));
        }