Ejemplo n.º 1
0
 RefV GetRef(Value v) =>
 v.Get(REF_FIELD);
Ejemplo n.º 2
0
        async Task SetUpAsync()
        {
            adminKey = await rootClient.Query(CreateKey(Obj("database", DbRef, "role", "admin")));

            adminClient = rootClient.NewSessionClient(adminKey.Get(SECRET_FIELD));

            await client.Query(CreateClass(Obj("name", "spells")));

            await client.Query(CreateClass(Obj("name", "characters")));

            await client.Query(CreateClass(Obj("name", "spellbooks")));

            await client.Query(CreateIndex(Obj(
                                               "name", "all_spells",
                                               "source", Class("spells")
                                               )));

            await client.Query(CreateIndex(Obj(
                                               "name", "spells_by_element",
                                               "source", Class("spells"),
                                               "terms", Arr(Obj("field", Arr("data", "element")))
                                               )));

            await client.Query(CreateIndex(Obj(
                                               "name", "elements_of_spells",
                                               "source", Class("spells"),
                                               "values", Arr(Obj("field", Arr("data", "element")))
                                               )));

            await client.Query(CreateIndex(Obj(
                                               "name", "spellbooks_by_owner",
                                               "source", Class("spellbooks"),
                                               "terms", Arr(Obj("field", Arr("data", "owner")))
                                               )));

            await client.Query(CreateIndex(Obj(
                                               "name", "spells_by_spellbook",
                                               "source", Class("spells"),
                                               "terms", Arr(Obj("field", Arr("data", "spellbook")))
                                               )));

            magicMissile = GetRef(await client.Query(
                                      Create(Class("spells"),
                                             Obj("data",
                                                 Obj(
                                                     "name", "Magic Missile",
                                                     "element", "arcane",
                                                     "cost", 10)))
                                      ));

            fireball = GetRef(await client.Query(
                                  Create(Class("spells"),
                                         Obj("data",
                                             Obj(
                                                 "name", "Fireball",
                                                 "element", "fire",
                                                 "cost", 10)))
                                  ));

            faerieFire = GetRef(await client.Query(
                                    Create(Class("spells"),
                                           Obj("data",
                                               Obj(
                                                   "name", "Faerie Fire",
                                                   "cost", 10,
                                                   "element", Arr(
                                                       "arcane",
                                                       "nature"
                                                       ))))
                                    ));

            summon = GetRef(await client.Query(
                                Create(Class("spells"),
                                       Obj("data",
                                           Obj(
                                               "name", "Summon Animal Companion",
                                               "element", "nature",
                                               "cost", 10)))
                                ));

            thor = GetRef(await client.Query(
                              Create(Class("characters"),
                                     Obj("data", Obj("name", "Thor")))
                              ));

            var thorsSpellbook = GetRef(await client.Query(
                                            Create(Class("spellbooks"),
                                                   Obj("data",
                                                       Obj("owner", thor)))
                                            ));

            thorSpell1 = GetRef(await client.Query(
                                    Create(Class("spells"),
                                           Obj("data",
                                               Obj("spellbook", thorsSpellbook)))
                                    ));

            thorSpell2 = GetRef(await client.Query(
                                    Create(Class("spells"),
                                           Obj("data",
                                               Obj("spellbook", thorsSpellbook)))
                                    ));
        }
Ejemplo n.º 3
0
        [Test] public async Task TestGetAnInstance()
        {
            Value instance = await client.Query(Get(magicMissile));

            Assert.AreEqual("Magic Missile", instance.Get(NAME_FIELD));
        }