public void should_create_select_query_with_complex_filter_and_sort() { // Setup var filter1 = new BlBinaryExpression { Operator = BlOperator.Eq, IsLeaf = true, PropName = "doors", Value = 4 }; var filter2 = new BlBinaryExpression { Operator = BlOperator.Eq, IsLeaf = true, PropName = "doors", Value = 2 }; var filter = new BlBinaryExpression { IsLeaf = false, Left = filter1, Right = filter2, Operator = BlOperator.And }; var sqlBuilder = new SqlQueryBuilder(); // Act var query = sqlBuilder.SelectPawnsFromTable("cars", 200, 200, filter, "model"); // Assert Assert.Equal("SELECT * FROM cars WHERE ((doors = 4) AND (doors = 2)) ORDER BY model Asc LIMIT 200 OFFSET 200", query); }
public void should_create_select_query_no_filter_no_sort() { // Setup var sqlBuilder = new SqlQueryBuilder(); // Act var query = sqlBuilder.SelectPawnsFromTable("cars", 0, 200); // Assert Assert.Equal("SELECT * FROM cars ORDER BY Id LIMIT 200 OFFSET 0", query); }
public void should_create_select_query_with_simple_filter_no_sort() { // Setup var filter = new BlBinaryExpression { Operator = BlOperator.Eq, IsLeaf = true, PropName = "doors", Value = 4 }; var sqlBuilder = new SqlQueryBuilder(); // Act var query = sqlBuilder.SelectPawnsFromTable("cars", 0, 200, filter); // Assert Assert.Equal("SELECT * FROM cars WHERE (doors = 4) ORDER BY Id LIMIT 200 OFFSET 0", query); }