/// <exception cref="System.Exception"></exception> public virtual void Test1() { DeleteBase("null.neodatis"); NeoDatis.Odb.ODB odb = Open("null.neodatis"); NeoDatis.Odb.Test.VO.Login.User user1 = new NeoDatis.Odb.Test.VO.Login.User("oli" , "oli@sdsadf", null); NeoDatis.Odb.Test.VO.Login.User user2 = new NeoDatis.Odb.Test.VO.Login.User("karine" , "karine@sdsadf", null); NeoDatis.Odb.Test.VO.Login.User user3 = new NeoDatis.Odb.Test.VO.Login.User(null, null, null); odb.Store(user1); odb.Store(user2); odb.Store(user3); odb.Close(); odb = Open("null.neodatis"); NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User), true); AssertEquals(3, l.Count); user1 = (NeoDatis.Odb.Test.VO.Login.User)l.Next(); AssertEquals("oli", user1.GetName()); AssertEquals("oli@sdsadf", user1.GetEmail()); AssertEquals(null, user1.GetProfile()); user2 = (NeoDatis.Odb.Test.VO.Login.User)l.Next(); AssertEquals("karine", user2.GetName()); AssertEquals("karine@sdsadf", user2.GetEmail()); AssertEquals(null, user2.GetProfile()); user3 = (NeoDatis.Odb.Test.VO.Login.User)l.Next(); AssertEquals(null, user3.GetName()); AssertEquals(null, user3.GetEmail()); AssertEquals(null, user3.GetProfile()); odb.Close(); DeleteBase("null.neodatis"); }
/// <exception cref="System.Exception"></exception> public virtual void Test9Ordering() { if (!isLocal) { return; } NeoDatis.Odb.ODB odb = Open("get.neodatis"); NeoDatis.Odb.Core.Query.NQ.SimpleNativeQuery query = new _SimpleNativeQuery_235(); query.OrderByDesc("name,email"); NeoDatis.Odb.Objects l = odb.GetObjects(query, true); int i = l.Count - 1; while (l.HasNext()) { NeoDatis.Odb.Test.VO.Login.User user = (NeoDatis.Odb.Test.VO.Login.User)l.Next(); // println(user.getName() + " / " + user.getEmail()); AssertEquals("olivier " + i / 3, user.GetName()); AssertEquals("[email protected] " + ((i % 3) + 1), user.GetEmail()); i--; } odb.Close(); }
/// <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 bool Match(NeoDatis.Odb.Test.VO.Login.User user) { return(user.GetProfile().GetName().StartsWith("profile") && user.GetEmail().StartsWith ("[email protected] 2")); }