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()); }
public virtual void TestCompareCollection8() { NeoDatis.Odb.Test.VO.Login.Function function = new NeoDatis.Odb.Test.VO.Login.Function ("login"); NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile ("operator", function); NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja" , "*****@*****.**", profile); 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); user.SetProfile(null); 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)); AssertTrue(comparator.HasChanged(instanceInfo, instanceInfo3)); AssertEquals(1, comparator.GetNbChanges()); AssertEquals(1, comparator.GetAttributeToSetToNull().Count); NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.SetAttributeToNullAction o = (NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.SetAttributeToNullAction )comparator.GetAttributeToSetToNull()[0]; AssertEquals(0, comparator.GetChangedAttributeActions().Count); AssertEquals(2, o.GetAttributeId()); }