Example #1
0
        public void TestCompareCollection6()
        {
            const string dbName = "introspectortest6.odb";

            DeleteBase(dbName);
            var odb = OdbFactory.Open(dbName);

            var function = new VO.Login.Function("login");
            var profile  = new Profile("operator", function);
            var user     = new User("olivier smadja", "*****@*****.**", profile);
            IObjectInfoComparator comparator = new ObjectInfoComparator();
            var ci = ClassIntrospector.Introspect(user.GetType(), true).GetMainClassInfo();

            var storageEngine = ((global::NDatabase.Odb)odb).GetStorageEngine();

            var instanceInfo =
                (NonNativeObjectInfo)
                new ObjectIntrospector(storageEngine.GetClassInfoProvider()).GetMetaRepresentation(user, true, null,
                                                                                                   new InstrumentationCallbackForStore(null,
                                                                                                                                       false));
            // Sets attributes offsets - this is normally done by reading then from
            // disk, but in this junit,
            // we must set them manually
            var offsets = new[] { 1L, 2L, 3L };
            var ids     = new[] { 1, 2, 3 };

            instanceInfo.GetHeader().SetAttributesIdentification(offsets);
            instanceInfo.GetHeader().SetAttributesIds(ids);
            instanceInfo.GetHeader().SetOid(OIDFactory.BuildObjectOID(1));
            var nnoiProfile = (NonNativeObjectInfo)instanceInfo.GetAttributeValueFromId(3);

            nnoiProfile.SetOid(OIDFactory.BuildObjectOID(2));

            var nnoiFunctions = (NonNativeObjectInfo)nnoiProfile.GetAttributeValueFromId(1);

            nnoiFunctions.SetOid(OIDFactory.BuildObjectOID(3));

            var nnoi = (NonNativeObjectInfo)instanceInfo.GetAttributeValueFromId(ci.GetAttributeId("profile"));

            nnoi.GetHeader().SetAttributesIdentification(offsets);
            nnoi.GetHeader().SetAttributesIds(ids);
            profile.SetName("ope");
            var instanceInfo3 =
                (NonNativeObjectInfo)
                new ObjectIntrospector(storageEngine.GetClassInfoProvider()).GetMetaRepresentation(user, true, null,
                                                                                                   new InstrumentationCallbackForStore(null,
                                                                                                                                       false));

            instanceInfo3.GetHeader().SetOid(OIDFactory.BuildObjectOID(1));
            nnoiProfile = (NonNativeObjectInfo)instanceInfo3.GetAttributeValueFromId(3);
            nnoiProfile.SetOid(OIDFactory.BuildObjectOID(2));

            nnoiFunctions = (NonNativeObjectInfo)nnoiProfile.GetAttributeValueFromId(1);
            nnoiFunctions.SetOid(OIDFactory.BuildObjectOID(3));

            AssertTrue(comparator.HasChanged(instanceInfo, instanceInfo3));
            AssertEquals(1, comparator.GetNbChanges());

            odb.Close();
        }
Example #2
0
        public void TestIntrospectWithNull()
        {
            const string dbName = "TestIntrospectWithNull.odb";

            DeleteBase(dbName);
            var odb = OdbFactory.Open(dbName);

            var user = new User("olivier smadja", "*****@*****.**", null);
            IObjectInfoComparator comparator = new ObjectInfoComparator();

            var storageEngine = ((global::NDatabase.Odb)odb).GetStorageEngine();

            var instanceInfo =
                (NonNativeObjectInfo)
                new ObjectIntrospector(storageEngine.GetClassInfoProvider()).GetMetaRepresentation(user, true, null,
                                                                                                   new InstrumentationCallbackForStore(null,
                                                                                                                                       false));
            // Sets attributes offsets - this is normally done by reading then from
            // disk, but in this junit,
            // we must set them manually
            var offsets = new[] { 1L, 2L, 3L };
            var ids     = new[] { 1, 2, 3 };

            instanceInfo.GetHeader().SetAttributesIdentification(offsets);
            instanceInfo.GetHeader().SetAttributesIds(ids);
            instanceInfo.GetHeader().SetOid(OIDFactory.BuildObjectOID(1));
            object o           = instanceInfo.GetAttributeValueFromId(3);
            var    nnoiProfile = (NonNativeObjectInfo)o;

            nnoiProfile.SetOid(OIDFactory.BuildObjectOID(2));
            user.SetName("Olivier Smadja");
            user.SetEmail("*****@*****.**");
            user.SetProfile(new Profile("pname"));
            var instanceInfo3 =
                (NonNativeObjectInfo)
                new ObjectIntrospector(storageEngine.GetClassInfoProvider()).GetMetaRepresentation(user, true, null,
                                                                                                   new InstrumentationCallbackForStore(null,
                                                                                                                                       false));

            instanceInfo3.GetHeader().SetOid(OIDFactory.BuildObjectOID(1));
            nnoiProfile = (NonNativeObjectInfo)instanceInfo3.GetAttributeValueFromId(3);
            nnoiProfile.SetOid(OIDFactory.BuildObjectOID(2));
            AssertTrue(comparator.HasChanged(instanceInfo, instanceInfo3));
            AssertEquals(3, comparator.GetNbChanges());

            odb.Close();
        }