/// <exception cref="System.Exception"></exception> public virtual void TestList1() { DeleteBase("list1.neodatis"); NeoDatis.Odb.ODB odb = Open("list1.neodatis"); long nb = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( PlayerWithList))); PlayerWithList player = new PlayerWithList ("kiko"); player.AddGame("volley-ball"); player.AddGame("squash"); player.AddGame("tennis"); player.AddGame("ping-pong"); odb.Store(player); odb.Close(); NeoDatis.Odb.ODB odb2 = Open("list1.neodatis"); NeoDatis.Odb.Objects <PlayerWithList> l = odb2.GetObjects <PlayerWithList>(true); Println(l); AssertEquals(nb + 1, l.Count); // gets last player PlayerWithList player2 = (PlayerWithList)l.GetFirst(); AssertEquals(player.ToString(), player2.ToString()); odb2.Close(); DeleteBase("list1.neodatis"); }
public virtual void TestList1WithNull() { DeleteBase("list1.ndb"); var odb = Open("list1.ndb"); var nb = odb.Query <PlayerWithList>().Count(); var player = new PlayerWithList("kiko"); player.AddGame("volley-ball"); player.AddGame("squash"); player.AddGame("tennis"); player.AddGame(null); odb.Store(player); odb.Close(); var odb2 = Open("list1.ndb"); var query = odb2.Query <PlayerWithList>(); var l = query.Execute <PlayerWithList>(true); AssertEquals(nb + 1, l.Count); // gets last player var player2 = l.GetFirst(); AssertEquals(player.GetGame(2), player2.GetGame(2)); odb2.Close(); DeleteBase("list1.ndb"); }
public virtual void TestBigList() { var baseName = GetBaseName(); var odb = Open(baseName); var size = 1000; var size2 = 4; var t0 = DateTime.Now.Ticks; for (var i = 0; i < size; i++) { var player = new PlayerWithList("player " + i); for (var j = 0; j < size2; j++) { player.AddGame("game " + j); } odb.Store(player); } odb.Close(); var t1 = DateTime.Now.Ticks; Console.WriteLine("insert : " + (t1 - t0) / 1000); var odb2 = Open(baseName); var query = odb2.Query <PlayerWithList>(); var l = query.Execute <PlayerWithList>(false); var t2 = DateTime.Now.Ticks; AssertEquals(size, l.Count); Console.WriteLine("get objects " + l.Count + " : " + (t2 - t1) / 1000); odb2.Close(); DeleteBase(baseName); }
public virtual void TestBigList() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); int size = 10000; int size2 = 4; long t0 = DateTime.Now.Ticks; for (int i = 0; i < size; i++) { PlayerWithList player = new PlayerWithList("player " + i); for (int j = 0; j < size2; j++) { player.AddGame("game " + j); } odb.Store(player); } odb.Close(); long t1 = DateTime.Now.Ticks; Console.WriteLine("insert : " + (t1 - t0) / 10000); NeoDatis.Odb.ODB odb2 = Open(baseName); NeoDatis.Odb.Objects <PlayerWithList> l = odb2.GetObjects <PlayerWithList>(false); long t2 = DateTime.Now.Ticks; AssertEquals(size, l.Count); Console.WriteLine("get objects " + l.Count + " : " + (t2 - t1) / 10000); odb2.Close(); DeleteBase(baseName); }
public virtual void TestCollectionWithContain() { IOdb odb = null; var baseName = GetBaseName(); try { odb = Open(baseName); var nb = odb.Query <PlayerWithList>().Count(); var player = new PlayerWithList("kiko"); player.AddGame("volley-ball"); player.AddGame("squash"); player.AddGame("tennis"); player.AddGame("ping-pong"); odb.Store(player); odb.Close(); odb = Open(baseName); var query = odb.Query <PlayerWithList>(); query.Descend("games").Constrain("tennis").Contains(); var l = query.Execute <PlayerWithList>(); AssertEquals(nb + 1, l.Count); } catch (Exception) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } } }
/// <exception cref="System.Exception"></exception> public virtual void TestCollectionWithContain() { NeoDatis.Odb.ODB odb = null; string baseName = GetBaseName(); try { odb = Open(baseName); long nb = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( PlayerWithList))); PlayerWithList player = new PlayerWithList ("kiko"); player.AddGame("volley-ball"); player.AddGame("squash"); player.AddGame("tennis"); player.AddGame("ping-pong"); odb.Store(player); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <PlayerWithList> l = odb.GetObjects <PlayerWithList>(new CriteriaQuery(Where.Contain("games", "tennis"))); AssertEquals(nb + 1, l.Count); } catch (System.Exception e) { if (odb != null) { odb.Rollback(); odb = null; } throw; } finally { if (odb != null) { odb.Close(); } } }