public void SpecificationWithPaging_AddsPaging() { var spec = new TestSpecification(); var baseQuery = $@"SELECT * FROM Table;"; spec.AddPaging(10, 3); var(query, _) = spec.Apply(baseQuery); Assert.Equal( Normalize(query), Normalize($"SELECT * FROM Table LIMIT 10 OFFSET 3;")); }
public void SpecificationWithAllFeatures_WorksCorrectly(string mode) { var spec = new TestSpecification(); var baseQuery = $@"SELECT * FROM Table;"; spec.AddCriteria(new[] { new Criteria("Foo", "Table", "a"), new Criteria("Baz", "Table", "b") }); spec.AddOrderBy(new[] { new OrderByColumn("Bar", mode), new OrderByColumn("Baz", mode) }); spec.AddPaging(10, 3); (var query, dynamic preparedStatementObject) = spec.Apply(baseQuery); Assert.Equal( Normalize(query), Normalize($@"SELECT * FROM Table WHERE Table.foo = @val0 AND Table.Baz = @val1 ORDER BY Bar {mode}, Baz {mode} LIMIT 10 OFFSET 3;")); Assert.True(preparedStatementObject.val0 == "a"); Assert.True(preparedStatementObject.val1 == "b"); }