public void ThrowExceptionIfAllFieldsWereIgnored() { // Setup var statementBuilder = new SqlDbStatementBuilder(); var queryBuilder = new QueryBuilder <ThrowExceptionIfAllFieldsWereIgnoredClass>(); var queryGroup = (QueryGroup)null; // Act/Assert Assert.Throws <InvalidOperationException>(() => statementBuilder.CreateQuery(queryBuilder, queryGroup)); }
public void ThrowExceptionIfThereAreNoQueryableFields() { // Setup var statementBuilder = new SqlDbStatementBuilder(); var queryBuilder = new QueryBuilder <ThrowExceptionIfThereAreNoQueryableFieldsClass>(); var queryGroup = (QueryGroup)null; // Act/Assert statementBuilder.CreateQuery(queryBuilder, queryGroup); }
public void TestWithFieldMapping() { // Setup var statementBuilder = new SqlDbStatementBuilder(); var queryBuilder = new QueryBuilder <TestWithFieldMappingClass>(); var queryGroup = (QueryGroup)null; // Act var actual = statementBuilder.CreateQuery(queryBuilder, queryGroup); var expected = $"" + $"SELECT [Field1], [Field2], [Field4] " + $"FROM [TestWithFieldMappingClass] ;"; // Assert Assert.AreEqual(expected, actual); }
public void TestWithAnyFieldsAtExpression() { // Setup var statementBuilder = new SqlDbStatementBuilder(); var queryBuilder = new QueryBuilder <TestWithAnyFieldsAtExpressionClass>(); var expression = new { AnyField = 1 }; var queryGroup = QueryGroup.Parse(expression); // Act var actual = statementBuilder.CreateQuery(queryBuilder, queryGroup); var expected = $"" + $"SELECT [Field1], [Field2], [Field3] " + $"FROM [TestWithAnyFieldsAtExpressionClass] " + $"WHERE ([AnyField] = @AnyField) ;"; // Assert Assert.AreEqual(expected, actual); }
public void TestWithDescendingOrderFields() { // Setup var statementBuilder = new SqlDbStatementBuilder(); var queryBuilder = new QueryBuilder <TestWithDescendingOrderFieldsClass>(); var queryGroup = (QueryGroup)null; var orderBy = OrderField.Parse(new { OrderField = Order.Descending }); // Act var actual = statementBuilder.CreateQuery(queryBuilder, queryGroup, orderBy); var expected = $"" + $"SELECT [Field1], [Field2], [Field3] " + $"FROM [TestWithDescendingOrderFieldsClass] " + $"ORDER BY [OrderField] DESC ;"; // Assert Assert.AreEqual(expected, actual); }