public void ShouldCombineConditionsUsingBothAndAndOr() { var builder = new TableQueryFilterBuilder <TestEntity>(); builder.And(b1 => { b1.Property("a").Equals(1); b1.Or(b2 => { b2.Property("b").Equals(2); b2.And(b3 => { b3.Property("c").Equals(3); b3.Not(b4 => b4.Property("d").Equals(4)); }); }); }); builder.Build().ShouldBe("(a eq 1) and ((b eq 2) or ((c eq 3) and (not (d eq 4))))"); builder = new TableQueryFilterBuilder <TestEntity>(); builder.Or(b1 => { b1.Property("a").Equals(1); b1.And(b2 => { b2.Property("b").Equals(2); b2.Or(b3 => { b3.Property("c").Equals(3); b3.Not(b4 => b4.Property("d").Equals(4)); }); }); }); builder.Build().ShouldBe("(a eq 1) or ((b eq 2) and ((c eq 3) or (not (d eq 4))))"); }
public void ShouldCombineConditionsWithAnd() { var builder = new TableQueryFilterBuilder <TestEntity>(); builder.And(x => x.Property("a").Equals(1)); builder.Build().ShouldBe("a eq 1"); builder = new TableQueryFilterBuilder <TestEntity>(); builder.And(x => { x.Property("a").Equals(1); x.Property("b").Equals(2); }); builder.Build().ShouldBe("(a eq 1) and (b eq 2)"); builder = new TableQueryFilterBuilder <TestEntity>(); builder.And(x => { x.Property("a").Equals(1); x.Property("b").Equals(2); }); builder.Build().ShouldBe("(a eq 1) and (b eq 2)"); builder = new TableQueryFilterBuilder <TestEntity>(); builder.And(x => { x.Property("a").Equals(1); x.Property("b").Equals(2); x.Property("c").Equals(3); }); builder.Build().ShouldBe("((a eq 1) and (b eq 2)) and (c eq 3)"); builder = new TableQueryFilterBuilder <TestEntity>(); builder.And(x => { x.Property("a").Equals(1); x.Property("b").Equals(2); x.Property("c").Equals(3); }); builder.Build().ShouldBe("((a eq 1) and (b eq 2)) and (c eq 3)"); }