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]}}}"); }
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")))); }
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")))))) ); }
public async Task TestEchoQuery() { var query = QueryV.Of((x, y) => Concat(Arr(x, "/", y))); Assert.AreEqual( query, await client.Query(query) ); }
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); }