public virtual void TestDeleteListElements() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("name" ); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("f1")); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("f2")); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("3")); odb.Store(p); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Profile> objects = odb.GetObjects <Profile>(); while (objects.HasNext()) { NeoDatis.Odb.Test.VO.Login.Profile profile = objects.Next(); System.Collections.Generic.IList <Function> functions = profile.GetFunctions(); for (int j = 0; j < functions.Count; j++) { odb.Delete(functions[j]); } odb.Delete(profile); } odb.Close(); }
public virtual void Test15() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; odb = Open(baseName); Function f1 = new Function( "function1"); Function f2 = new Function( "function2"); odb.Store(f1); odb.Store(f2); AssertEquals(2, odb.Count(new CriteriaQuery (typeof(Function)))); odb.Delete(f1); odb.Delete(f2); AssertEquals(0, odb.Count(new CriteriaQuery (typeof(Function)))); odb.Store(f1); odb.Store(f2); AssertEquals(2, odb.Count(new CriteriaQuery (typeof(Function)))); odb.Close(); odb = Open(baseName); AssertEquals(2, odb.GetObjects <Function>().Count ); odb.Close(); DeleteBase(baseName); }
public virtual void Test13() { if (!isLocal) { return; } string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; DeleteBase(baseName); odb = Open(baseName); Function f1 = new Function( "function1"); Function f2 = new Function( "function2"); Function f3 = new Function( "function3"); odb.Store(f1); odb.Store(f2); odb.Store(f3); NeoDatis.Odb.OID idf1 = odb.GetObjectId(f1); NeoDatis.Odb.OID idf2 = odb.GetObjectId(f2); NeoDatis.Odb.OID idf3 = odb.GetObjectId(f3); long p1 = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy.GetEngine(odb).GetObjectReader ().GetObjectPositionFromItsOid(idf1, true, false); long p2 = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy.GetEngine(odb).GetObjectReader ().GetObjectPositionFromItsOid(idf2, true, false); long p3 = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy.GetEngine(odb).GetObjectReader ().GetObjectPositionFromItsOid(idf3, true, false); odb.Close(); try { odb = Open(baseName); f1 = (Function)odb.GetObjectFromId(idf1); f2 = (Function)odb.GetObjectFromId(idf2); f3 = (Function)odb.GetObjectFromId(idf3); odb.Delete(f3); odb.Delete(f2); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(); odb.Close(); AssertEquals(1, l.Count); } catch (NeoDatis.Odb.ODBRuntimeException e) { DeleteBase(baseName); throw; } DeleteBase(baseName); }
/// <exception cref="System.Exception"></exception> public virtual void T1estN3() { NeoDatis.Odb.ODB odb = test.Open("acid1"); if (simpleObject) { NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(new CriteriaQuery(Where.Equal("name", "new name"))); odb.Delete(objects.GetFirst()); } else { NeoDatis.Odb.Objects <User> objects = odb.GetObjects <User>(new CriteriaQuery(Where.Equal("name", "new name"))); odb.Delete(objects.GetFirst()); } odb.Commit(); }
/// <summary>one object has a list.</summary> /// <remarks> /// one object has a list. we delete one of the object of the list of the /// object. And the main object still has it /// </remarks> /// <exception cref="System.Exception">System.Exception</exception> public virtual void TestDeletingOneElementOfTheList() { if (!testNewFeature) { return; } string baseName = GetBaseName(); DeleteBase(baseName); NeoDatis.Odb.ODB odb = Open(baseName); NeoDatis.Odb.Test.VO.Sport.Team t1 = new NeoDatis.Odb.Test.VO.Sport.Team("team1"); t1.AddPlayer(Player("player1", new System.DateTime(), new Sport("sport1"))); t1.AddPlayer(new NeoDatis.Odb.Test.VO.Sport.Player("player2", new System.DateTime(), new Sport.Sport("sport2"))); odb.Store(t1); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Team> teams = odb.GetObjects <Team>(); Team team = teams.GetFirst(); AssertEquals(2, team.GetPlayers().Count); NeoDatis.Odb.Objects <Player> players = odb.GetObjects <Player>(); Player p1 = players.GetFirst(); odb.Delete(p1); odb.Close(); AssertEquals(1, team.GetPlayers().Count); }
/// <summary> /// Bug when deleting the first object of unconnected zone when commited zone /// already have at least one object. /// </summary> /// <remarks> /// Bug when deleting the first object of unconnected zone when commited zone /// already have at least one object. /// Detected running the polePosiiton Bahrain circuit. /// </remarks> /// <exception cref="System.Exception">System.Exception</exception> public virtual void Test21() { NeoDatis.Odb.ODB odb = null; string baseName = GetBaseName(); odb = Open(baseName); NeoDatis.Odb.Test.VO.Login.Function f0 = new NeoDatis.Odb.Test.VO.Login.Function( "function0"); odb.Store(f0); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function( "function1"); odb.Store(f1); NeoDatis.Odb.Test.VO.Login.Function f2 = new NeoDatis.Odb.Test.VO.Login.Function( "function2"); odb.Store(f2); odb.Delete(f1); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function))); AssertEquals(2, objects.Count); odb.Close(); }
/// <summary>creates 3 objects.</summary> /// <remarks>creates 3 objects. Delete the 2th. And create 3 new objects</remarks> /// <exception cref="System.Exception">System.Exception</exception> public virtual void Test17() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; DeleteBase(baseName); odb = Open(baseName); NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function( "function1"); NeoDatis.Odb.Test.VO.Login.Function f2 = new NeoDatis.Odb.Test.VO.Login.Function( "function2"); NeoDatis.Odb.Test.VO.Login.Function f3 = new NeoDatis.Odb.Test.VO.Login.Function( "function2"); odb.Store(f1); odb.Store(f2); odb.Store(f3); AssertEquals(3, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); odb.Delete(f2); AssertEquals(2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); // odb.store(f1); odb.Store(f2); // odb.store(f3); AssertEquals(3, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); odb.Close(); odb = Open(baseName); AssertEquals(3, odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).Count ); odb.Close(); DeleteBase(baseName); }
/// <exception cref="System.Exception"></exception> public virtual void Test1() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); long n = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Login.Function))); NeoDatis.Odb.Test.VO.Login.Function function1 = new NeoDatis.Odb.Test.VO.Login.Function ("function1"); NeoDatis.Odb.Test.VO.Login.Function function2 = new NeoDatis.Odb.Test.VO.Login.Function ("function2"); NeoDatis.Odb.Test.VO.Login.Function function3 = new NeoDatis.Odb.Test.VO.Login.Function ("function3"); odb.Store(function1); odb.Store(function2); odb.Store(function3); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects l = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "function2"))); NeoDatis.Odb.Test.VO.Login.Function function = (NeoDatis.Odb.Test.VO.Login.Function )l.GetFirst(); odb.Delete(function); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects l2 = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), true); AssertEquals(n + 2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); odb.Close(); DeleteBase(baseName); }
public virtual void Test1() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); decimal n = odb.Count(new CriteriaQuery(typeof( Function))); Function function1 = new Function ("function1"); Function function2 = new Function ("function2"); Function function3 = new Function ("function3"); odb.Store(function1); odb.Store(function2); odb.Store(function3); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(new CriteriaQuery(Where.Equal("name", "function2"))); Function function = l.GetFirst(); odb.Delete(function); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Function> l2 = odb.GetObjects <Function>(true); AssertEquals(n + 2, odb.Count(new CriteriaQuery (typeof(Function)))); odb.Close(); DeleteBase(baseName); }
public virtual void Test5_deleteNullObject() { NeoDatis.Odb.ODB odb = null; string baseName = GetBaseName(); odb = Open(baseName); Function f = new Function("function1" ); odb.Store(f); NeoDatis.Odb.OID oid = odb.GetObjectId(f); try { odb.Delete(null); Fail("Should have thrown an exception: trying to delete a null object"); } catch (NeoDatis.Odb.ODBRuntimeException) { odb.Close(); DeleteBase(baseName); } catch (System.Exception) { Fail("Should have thrown an OdbRuntimeException: trying to delete a null object"); } }
public virtual void Test21() { NeoDatis.Odb.ODB odb = null; string baseName = GetBaseName(); odb = Open(baseName); Function f0 = new Function( "function0"); odb.Store(f0); odb.Close(); odb = Open(baseName); Function f1 = new Function( "function1"); odb.Store(f1); Function f2 = new Function( "function2"); odb.Store(f2); odb.Delete(f1); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(new CriteriaQuery()); AssertEquals(2, objects.Count); odb.Close(); }
public virtual void Test8RollbackDeleteAndStore() { DeleteBase("rollback.neodatis"); NeoDatis.Odb.ODB odb = Open("rollback.neodatis", "u1", "p1"); odb.Store(new Function("f1")); odb.Store(new Function("f2")); odb.Store(new Function("f3")); odb.Close(); odb = Open("rollback.neodatis", "u1", "p1"); NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(); while (objects.HasNext()) { Function f = (Function)objects .Next(); f.SetName(OdbString.Substring(f.GetName(), 1)); odb.Store(f); } objects.Reset(); while (objects.HasNext()) { odb.Delete(objects.Next()); } for (int i = 0; i < 500; i++) { odb.Store(new Function("f3 - " + i)); } odb.Rollback(); odb.Close(); odb = Open("rollback.neodatis", "u1", "p1"); AssertEquals(3, odb.GetObjects <Function>().Count ); odb.Close(); }
public virtual void Test4() { string baseName = GetBaseName(); int n = isLocal ? 1000 : 10; NeoDatis.Odb.ODB odb = Open(baseName); long size = odb.Count(new CriteriaQuery(typeof(Function))); for (int i = 0; i < n; i++) { Function login = new Function("login - " + (i + 1)); odb.Store(login); AssertEquals(size + i + 1, odb.Count(new CriteriaQuery(typeof(Function)))); Console.WriteLine(i); } // IStorageEngine engine = Dummy.getEngine(odb); odb.Commit(); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(true); int j = 0; while (l.HasNext()) { Console.WriteLine(" i=" + j); Function f = (Function)l.Next(); odb.Delete(f); NeoDatis.Odb.Objects <Function> l2 = odb.GetObjects <Function>(); AssertEquals(size + n - (j + 1), l2.Count); j++; } odb.Commit(); odb.Close(); DeleteBase(baseName); }
/// <summary>a problem reported by glsender - 1875544</summary> /// <exception cref="System.Exception"></exception> public virtual void Test1() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); NeoDatis.Odb.Test.Cache.MyObjectWithMyHashCode my = null; // creates 1000 objects for (int i = 0; i < 1000; i++) { my = new NeoDatis.Odb.Test.Cache.MyObjectWithMyHashCode(System.Convert.ToInt64(1000 )); odb.Store(my); } odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.Cache.MyObjectWithMyHashCode )); AssertEquals(1000, objects.Count); while (objects.HasNext()) { my = (NeoDatis.Odb.Test.Cache.MyObjectWithMyHashCode)objects.Next(); odb.Delete(my); } odb.Close(); odb = Open(baseName); objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.Cache.MyObjectWithMyHashCode)); odb.Close(); NeoDatis.Tool.IOUtil.DeleteFile(baseName); AssertEquals(0, objects.Count); }
public virtual void Test10() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; odb = Open(baseName); long size = odb.GetObjects <Function>().Count; Function f1 = new Function( "function1"); odb.Store(f1); odb.Close(); odb = Open(baseName); Function f1bis = (Function) odb.GetObjects <Function>().GetFirst(); odb.Delete(f1bis); odb.Close(); odb = Open(baseName); AssertEquals(size, odb.GetObjects <Function>().Count ); odb.Store(new Function("last function")); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(); odb.Close(); AssertEquals(size + 1, l.Count); }
public virtual void Test9() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; odb = Open(baseName); Function f1 = new Function( "function1"); Function f2 = new Function( "function2"); Function f3 = new Function( "function3"); odb.Store(f1); odb.Store(f2); odb.Store(f3); NeoDatis.Odb.OID id = odb.GetObjectId(f3); odb.Close(); odb = Open(baseName); Function f3bis = (Function) odb.GetObjectFromId(id); odb.Delete(f3bis); odb.Close(); odb = Open(baseName); odb.Store(new Function("last function")); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(); odb.Close(); AssertEquals(3, l.Count); }
/// <exception cref="System.Exception"></exception> public virtual void Test2() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); long nbFunctions = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function))); long nbProfiles = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Profile))); NeoDatis.Odb.Test.VO.Login.Function function1 = new NeoDatis.Odb.Test.VO.Login.Function ("function1"); NeoDatis.Odb.Test.VO.Login.Function function2 = new NeoDatis.Odb.Test.VO.Login.Function ("function2"); NeoDatis.Odb.Test.VO.Login.Function function3 = new NeoDatis.Odb.Test.VO.Login.Function ("function3"); System.Collections.IList functions = new System.Collections.ArrayList(); functions.Add(function1); functions.Add(function2); functions.Add(function3); NeoDatis.Odb.Test.VO.Login.Profile profile1 = new NeoDatis.Odb.Test.VO.Login.Profile ("profile1", functions); NeoDatis.Odb.Test.VO.Login.Profile profile2 = new NeoDatis.Odb.Test.VO.Login.Profile ("profile2", function1); odb.Store(profile1); odb.Store(profile2); odb.Close(); odb = Open(baseName); // checks functions NeoDatis.Odb.Objects lfunctions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), true); AssertEquals(nbFunctions + 3, lfunctions.Count); NeoDatis.Odb.Objects l = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "function2"))); NeoDatis.Odb.Test.VO.Login.Function function = (NeoDatis.Odb.Test.VO.Login.Function )l.GetFirst(); odb.Delete(function); odb.Close(); odb = Open(baseName); AssertEquals(nbFunctions + 2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); NeoDatis.Odb.Objects l2 = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), true); // check Profile 1 NeoDatis.Odb.Objects lprofile = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Profile), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "profile1"))); NeoDatis.Odb.Test.VO.Login.Profile p1 = (NeoDatis.Odb.Test.VO.Login.Profile)lprofile .GetFirst(); AssertEquals(2, p1.GetFunctions().Count); odb.Close(); DeleteBase(baseName); }
/// <exception cref="System.Exception"></exception> public virtual void T1estJ1() { test.DeleteBase("acid1"); NeoDatis.Odb.ODB odb = test.Open("acid1"); odb.Store(GetInstance("f1")); odb.Store(GetInstance("f2")); odb.Store(GetInstance("f3")); odb.Commit(); object o = GetInstance("f4"); odb.Store(o); odb.Delete(o); }
/// <exception cref="System.Exception"></exception> public virtual void T1estK1() { test.DeleteBase("acid1"); NeoDatis.Odb.ODB odb = test.Open("acid1"); odb.Store(GetInstance("f1")); odb.Store(GetInstance("f2")); NeoDatis.Odb.OID oid = odb.Store(GetInstance("f3")); odb.Commit(); object o = odb.GetObjectFromId(oid); odb.Delete(o); odb.Rollback(); }
public virtual void Test2() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); long nbFunctions = odb.Count(new CriteriaQuery (typeof(Function))); decimal nbProfiles = odb.Count(new CriteriaQuery (typeof(Profile))); Function function1 = new Function ("function1"); Function function2 = new Function ("function2"); Function function3 = new Function ("function3"); System.Collections.Generic.List <Function> functions = new System.Collections.Generic.List <Function>(); functions.Add(function1); functions.Add(function2); functions.Add(function3); Profile profile1 = new Profile("profile1", functions); Profile profile2 = new Profile("profile2", function1); odb.Store(profile1); odb.Store(profile2); odb.Close(); odb = Open(baseName); // checks functions NeoDatis.Odb.Objects <Function> lfunctions = odb.GetObjects <Function>(true); AssertEquals(nbFunctions + 3, lfunctions.Count); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(new CriteriaQuery(Where.Equal("name", "function2"))); Function function = l.GetFirst(); odb.Delete(function); odb.Close(); odb = Open(baseName); AssertEquals(nbFunctions + 2, odb.Count(new CriteriaQuery (typeof(Function)))); NeoDatis.Odb.Objects <Function> l2 = odb.GetObjects <Function>(true); // check Profile 1 NeoDatis.Odb.Objects <Profile> lprofile = odb.GetObjects <Profile>(new CriteriaQuery(Where.Equal("name", "profile1"))); Profile p1 = lprofile.GetFirst(); AssertEquals(2, p1.GetFunctions().Count); odb.Close(); DeleteBase(baseName); }
/// <exception cref="System.Exception"></exception> public virtual void Test3() { string baseName = GetBaseName(); string baseName2 = "2" + baseName; NeoDatis.Odb.ODB odb = Open(baseName); int size = 1000; for (int i = 0; i < size; i++) { odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("function " + i)); } odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), false); int j = 0; while (objects.HasNext() && j < objects.Count - 1) { odb.Delete(objects.Next()); j++; } odb.Close(); odb = Open(baseName); AssertEquals(1, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); odb.Close(); if (isLocal) { odb = Open(baseName); odb.DefragmentTo(NeoDatis.Odb.Test.ODBTest.Directory + baseName2); odb.Close(); odb = Open(baseName2); AssertEquals(1, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); odb.Close(); } DeleteBase(baseName); DeleteBase(baseName2); }
/// <exception cref="System.Exception"></exception> public virtual void T1estH1() { test.DeleteBase("acid1"); NeoDatis.Odb.ODB odb = test.Open("acid1"); int size = 1000; NeoDatis.Odb.OID[] oids = new NeoDatis.Odb.OID[size]; for (int i = 0; i < size; i++) { oids[i] = odb.Store(GetInstance("f" + i)); if (simpleObject) { NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)odb. GetObjectFromId(oids[i]); f.SetName("function " + i); odb.Store(f); odb.Delete(f); oids[i] = odb.Store(f); odb.Delete(f); oids[i] = odb.Store(f); odb.Delete(f); oids[i] = odb.Store(f); } else { NeoDatis.Odb.Test.VO.Login.User f = (NeoDatis.Odb.Test.VO.Login.User)odb.GetObjectFromId (oids[i]); f.SetName("function " + i); odb.Store(f); odb.Delete(f); oids[i] = odb.Store(f); odb.Delete(f); oids[i] = odb.Store(f); odb.Delete(f); oids[i] = odb.Store(f); } } for (int i = 0; i < size; i++) { object o = odb.GetObjectFromId(oids[i]); odb.Delete(o); } }
public virtual void Test5RollbackDelete() { DeleteBase("rollback.neodatis"); NeoDatis.Odb.ODB odb = Open("rollback.neodatis", "u1", "p1"); odb.Store(new Function("f1")); odb.Store(new Function("f2")); odb.Store(new Function("f3")); odb.Close(); odb = Open("rollback.neodatis", "u1", "p1"); NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(); while (objects.HasNext()) { odb.Delete(objects.Next()); } odb.Rollback(); odb.Close(); odb = Open("rollback.neodatis", "u1", "p1"); AssertEquals(3, odb.GetObjects <Function>().Count ); odb.Close(); }
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); User user = new User("name" , "email", new Profile("p1", new Function ("function"))); odb.Store(user); odb.Close(); odb = Open(Name); Profile p = (Profile)odb.GetObjects <Profile>().GetFirst(); odb.Delete(p); odb.Close(); odb = Open(Name); User user3 = (User)odb.GetObjects <User>().GetFirst(); AssertNull(user3.GetProfile()); user3.SetProfile(new Profile("new profile", new Function ("f1"))); user3.SetEmail("email2"); user3.SetName("name2"); odb.Store(user3); odb.Close(); odb = Open(Name); User user4 = (User)odb.GetObjects <User>().GetFirst(); odb.Close(); DeleteBase(Name); AssertEquals("new profile", user4.GetProfile().GetName()); AssertEquals("email2", user4.GetEmail()); AssertEquals("name2", user4.GetName()); }
/// <exception cref="System.Exception"></exception> public virtual void Test5() { NeoDatis.Odb.ODB odb = null; string baseName = GetBaseName(); odb = Open(baseName); NeoDatis.Odb.Test.VO.Login.Function f = new NeoDatis.Odb.Test.VO.Login.Function("function1" ); odb.Store(f); NeoDatis.Odb.OID id = odb.GetObjectId(f); try { odb.Delete(f); NeoDatis.Odb.OID id2 = odb.GetObjectId(f); Fail("The object has been deleted, the id should have been marked as deleted"); } catch (NeoDatis.Odb.ODBRuntimeException) { odb.Close(); DeleteBase(baseName); } }
/// <exception cref="System.Exception"></exception> public virtual void Test4() { string baseName = GetBaseName(); int n = isLocal ? 1000 : 10; NeoDatis.Odb.ODB odb = Open(baseName); long size = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Login.Function))); for (int i = 0; i < n; i++) { NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function ("login - " + (i + 1)); odb.Store(login); AssertEquals(size + i + 1, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function)))); } // IStorageEngine engine = Dummy.getEngine(odb); odb.Commit(); NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function ), true); int j = 0; while (l.HasNext()) { // println("i="+i); NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)l.Next (); odb.Delete(f); NeoDatis.Odb.Objects l2 = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function )); AssertEquals(size + n - (j + 1), l2.Count); j++; } odb.Commit(); odb.Close(); DeleteBase(baseName); }
/// <exception cref="System.Exception"></exception> public virtual void Test30() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); NeoDatis.Odb.OID oid1 = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("function 1" )); NeoDatis.Odb.OID oid2 = odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("function 2" )); odb.Close(); Println(oid1); Println(oid2); odb = Open(baseName); odb.Delete(odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).GetFirst() ); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)odb. GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).GetFirst(); odb.Close(); DeleteBase(baseName); AssertEquals("function 2", f.GetName()); }
/// <summary>Test : delete the unique object</summary> /// <exception cref="System.Exception">System.Exception</exception> public virtual void Test11() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; odb = Open(baseName); long size = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Login.Function))); NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function( "function1"); odb.Store(f1); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Test.VO.Login.Function f1bis = (NeoDatis.Odb.Test.VO.Login.Function) odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).GetFirst(); odb.Delete(f1bis); odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("last function")); odb.Close(); odb = Open(baseName); AssertEquals(size + 1, odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function) ).Count); odb.Close(); }
public virtual void Test6() { NeoDatis.Odb.ODB odb = null; string baseName = GetBaseName(); odb = Open(baseName); Function f = new Function("function1" ); odb.Store(f); NeoDatis.Odb.OID id = odb.GetObjectId(f); odb.Commit(); try { odb.Delete(f); odb.GetObjectFromId(id); Fail("The object has been deleted, the id should have been marked as deleted"); } catch (NeoDatis.Odb.ODBRuntimeException) { odb.Close(); DeleteBase("t-delete1.neodatis"); } }
public virtual void Test7() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; odb = Open(baseName); Function f1 = new Function( "function1"); Function f2 = new Function( "function2"); Function f3 = new Function( "function3"); odb.Store(f1); odb.Store(f2); odb.Store(f3); NeoDatis.Odb.OID id = odb.GetObjectId(f3); odb.Close(); try { odb = Open(baseName); Function f3bis = (Function) odb.GetObjectFromId(id); odb.Delete(f3bis); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>(); odb.Close(); AssertEquals(2, l.Count); } catch (NeoDatis.Odb.ODBRuntimeException) { odb.Close(); DeleteBase(baseName); } }