예제 #1
0
        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));
        }
예제 #2
0
        public void ThrowExceptionIfThereAreNoQueryableFields()
        {
            // Setup
            var statementBuilder = new SqlDbStatementBuilder();
            var queryBuilder     = new QueryBuilder <ThrowExceptionIfThereAreNoQueryableFieldsClass>();
            var queryGroup       = (QueryGroup)null;

            // Act/Assert
            statementBuilder.CreateQuery(queryBuilder, queryGroup);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }