/// <summary>Stores an object User that has a non null reference to a Profile.</summary> /// <remarks> /// Stores an object User that has a non null reference to a Profile. Then /// deletes the profile. Loads the user again and updates the user profile /// with a new created profile. ODB did not detect the change Detected by /// Olivier. /// </remarks> /// <exception cref="System.Exception">System.Exception</exception> public virtual void Test8() { // reset counter to checks update type (normal or updates) NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter.ResetNbUpdates(); if (!isLocal) { return; } DeleteBase(Name); NeoDatis.Odb.ODB odb = Open(Name); NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("name" , "email", new NeoDatis.Odb.Test.VO.Login.Profile("p1", new NeoDatis.Odb.Test.VO.Login.Function ("function"))); odb.Store(user); odb.Close(); odb = Open(Name); NeoDatis.Odb.Test.VO.Login.Profile p = (NeoDatis.Odb.Test.VO.Login.Profile)odb.GetObjects (typeof(NeoDatis.Odb.Test.VO.Login.Profile)).GetFirst(); odb.Delete(p); odb.Close(); odb = Open(Name); NeoDatis.Odb.Test.VO.Login.User user3 = (NeoDatis.Odb.Test.VO.Login.User)odb.GetObjects (typeof(NeoDatis.Odb.Test.VO.Login.User)).GetFirst(); AssertNull(user3.GetProfile()); user3.SetProfile(new NeoDatis.Odb.Test.VO.Login.Profile("new profile", new NeoDatis.Odb.Test.VO.Login.Function ("f1"))); user3.SetEmail("email2"); user3.SetName("name2"); odb.Store(user3); odb.Close(); odb = Open(Name); NeoDatis.Odb.Test.VO.Login.User user4 = (NeoDatis.Odb.Test.VO.Login.User)odb.GetObjects (typeof(NeoDatis.Odb.Test.VO.Login.User)).GetFirst(); odb.Close(); DeleteBase(Name); AssertEquals("new profile", user4.GetProfile().GetName()); AssertEquals("email2", user4.GetEmail()); AssertEquals("name2", user4.GetName()); }
public virtual void TestCompareCollection1() { NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja" , "*****@*****.**", new NeoDatis.Odb.Test.VO.Login.Profile("operator", new NeoDatis.Odb.Test.VO.Login.Function("login"))); NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.IObjectInfoComparator comparator = new NeoDatis.Odb.Impl.Core.Layers.Layer2.Meta.Compare.ObjectInfoComparator(); NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = classIntrospector.Introspect( user.GetType(), true).GetMainClassInfo(); NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo )new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true , null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrospectionCallbackForStore (null, null, false)); // Sets attributes offsets - this is normally done by reading then from // disk, but in this junit, // we must set them manually long[] offsets = new long[] { 1L, 2L, 3L }; int[] ids = new int[] { 1, 2, 3 }; instanceInfo.GetHeader().SetAttributesIdentification(offsets); instanceInfo.GetHeader().SetAttributesIds(ids); instanceInfo.GetHeader().SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(1 )); NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoiProfile = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo )instanceInfo.GetAttributeValueFromId(2); nnoiProfile.SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(2)); user.SetName("Olivier Smadja"); NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo3 = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo )new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true , null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrospectionCallbackForStore (null, null, false)); instanceInfo3.GetHeader().SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID( 1)); nnoiProfile = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo)instanceInfo3 .GetAttributeValueFromId(2); nnoiProfile.SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(2)); AssertTrue(comparator.HasChanged(instanceInfo, instanceInfo3)); AssertEquals(1, comparator.GetNbChanges()); AssertEquals(1, comparator.GetChangedAttributeActions().Count); NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.ChangedNativeAttributeAction cnaa = (NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.ChangedNativeAttributeAction)comparator .GetChangedAttributeActions()[0]; AssertEquals("Olivier Smadja", cnaa.GetNoiWithNewValue().GetObject()); }