public void TestQuery()
        {
            AssertJsonEqual(Query(Lambda("x", Add(Var("x"), 1))), "{\"query\":{\"lambda\":\"x\",\"expr\":{\"add\":[{\"var\":\"x\"},1]}}}");
            AssertJsonEqual(Query(Lambda(x => Add(x, 1))), "{\"query\":{\"lambda\":\"x\",\"expr\":{\"add\":[{\"var\":\"x\"},1]}}}");

            AssertJsonEqual(QueryV.Of("x", Add(Var("x"), 1)), "{\"@query\":{\"lambda\":\"x\",\"expr\":{\"add\":[{\"var\":\"x\"},1]}}}");
            AssertJsonEqual(QueryV.Of(x => Add(x, 1)), "{\"@query\":{\"lambda\":\"x\",\"expr\":{\"add\":[{\"var\":\"x\"},1]}}}");
        }
Example #2
0
        public async Task TestCreateFunction()
        {
            var query = QueryV.Of((x, y) => Concat(Arr(x, "/", y)));

            await client.Query(CreateFunction(Obj("name", "concat_with_slash", "body", query)));

            Assert.AreEqual(BooleanV.True, await client.Query(Exists(new FunctionV("concat_with_slash"))));
        }
Example #3
0
        public async Task TestWrapQuery()
        {
            var query = QueryV.Of((x, y) => Concat(Arr(x, "/", y)));

            Assert.AreEqual(
                query,
                await client.Query(Query(Lambda(Arr("x", "y"), Concat(Arr(Var("x"), "/", Var("y"))))))
                );
        }
Example #4
0
        public async Task TestEchoQuery()
        {
            var query = QueryV.Of((x, y) => Concat(Arr(x, "/", y)));

            Assert.AreEqual(
                query,
                await client.Query(query)
                );
        }
Example #5
0
        public async Task TestCallFunction()
        {
            var query = QueryV.Of((x, y) => Concat(Arr(x, "/", y)));

            await client.Query(CreateFunction(Obj("name", "my_concat", "body", query)));

            var result = await client.Query(Call(new FunctionV("my_concat"), "a", "b"));

            Assert.AreEqual(StringV.Of("a/b"), result);
        }