public void SimpleTest() { //AQuery query = _db.Query.Filter(FilterBuilder<Dummy>.Eq( x => x.Foo, "asd")); AQuery query = _db.Query.Filter(AFilter.Eq(AValue <Dummy> .Field(x => x.Foo), AValue.Bind("asd"))); Assert.AreEqual("FILTER x.Foo == @var0", query.GetExpression()); Assert.AreEqual("asd", query.GetBindedVars()[0]); }
public void TypeTest() { Type dummyType = typeof(Dummy); //AQuery query = _db.Query.Filter(FilterBuilder<Dummy>.Eq(x => x.GetType(), dummyType)); AQuery query = _db.Query.Filter(AFilter.Eq(AValue <Dummy> .Field(x => x.GetType()), AValue.Bind(dummyType))); Assert.AreEqual("FILTER x.$type == @var0", query.GetExpression()); Assert.AreEqual(dummyType.FullName + ", " + dummyType.Assembly.GetName().Name, query.GetBindedVars()[0]); }
public void IfTest() { AQuery query = _db.Query .Let("x", AValue.If( AFilter.Eq(AValue <Dummy> .Field(x => x.Bar), AValue.Bind(2)), AValue <Dummy> .Field(x => x.Baz), AValue.Bind(0) )); Assert.AreEqual("LET x = (x.Bar == @var0 ? x.Baz : @var1)", query.GetExpression()); Assert.AreEqual(2, query.GetBindedVars()[0]); Assert.AreEqual(0, query.GetBindedVars()[1]); }
public void OrTest() { AQuery query = _db.Query.Filter( AFilter.Or( AFilter.Eq(AValue <Dummy> .Field(x => x.Foo), AValue.Bind("asd")), AFilter.Gt(AValue <Dummy> .Field(x => x.Bar), AValue.Bind(1)) ) ); Assert.AreEqual("FILTER (x.Foo == @var0 OR x.Bar > @var1)", query.GetExpression()); Assert.AreEqual("asd", query.GetBindedVars()[0]); Assert.AreEqual(1, query.GetBindedVars()[1]); }