public virtual void TestArray1() { IOdb odb = null; try { DeleteBase("array1.ndb"); odb = Open("array1.ndb"); decimal nb = odb.Query<PlayerWithArray>().Count(); var player = new PlayerWithArray("kiko"); player.AddGame("volley-ball"); player.AddGame("squash"); player.AddGame("tennis"); player.AddGame("ping-pong"); odb.Store(player); odb.Close(); odb = Open("array1.ndb"); var query = odb.Query<PlayerWithArray>(); var l = query.Execute<PlayerWithArray>(true); AssertEquals(nb + 1, l.Count); // gets first player var player2 = l.GetFirst(); AssertEquals(player.ToString(), (string) player2.ToString()); } catch (Exception e) { if (odb != null) { odb.Rollback(); odb = null; } Console.WriteLine(e); throw e; } finally { if (odb != null) odb.Close(); DeleteBase("array1.ndb"); } }
public virtual void TestArrayQuery() { DeleteBase("array4.ndb"); decimal nb; using (var odb = Open("array4.ndb")) { nb = odb.Query<PlayerWithArray>().Count(); var player = new PlayerWithArray("kiko"); player.AddGame("volley-ball"); player.AddGame("squash"); player.AddGame("tennis"); player.AddGame("ping-pong"); odb.Store(player); } using (var odb = Open("array4.ndb")) { var query = odb.Query<PlayerWithArray>(); query.Descend("games").Constrain("tennis").Contains(); var l = query.Execute<PlayerWithArray>(); AssertEquals(nb + 1, l.Count); } }