Beispiel #1
0
        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);
        }
Beispiel #2
0
        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();
            }
        }
Beispiel #3
0
 public virtual void TestList2()
 {
     DeleteBase("list1.ndb");
     var odb = Open("list1.ndb");
     var nb = odb.Query<PlayerWithList>().Count();
     var player = new PlayerWithList("kiko");
     player.SetGames(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);
     odb2.Close();
     DeleteBase("list1.ndb");
 }
Beispiel #4
0
 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");
 }