Ejemplo n.º 1
0
        public void ThrowExceptionIfTheIdentityFieldIsNotThePrimaryField()
        {
            // Setup
            var statementBuilder = new SqlDbStatementBuilder();
            var queryBuilder     = new QueryBuilder <ThrowExceptionIfTheIdentityFieldIsNotThePrimaryFieldClass>();
            var queryGroup       = (QueryGroup)null;

            // Act/Assert
            Assert.Throws <InvalidOperationException>(() => statementBuilder.CreateUpdate(queryBuilder, queryGroup));
        }
Ejemplo n.º 2
0
        public void TestWithFieldMapping()
        {
            // Setup
            var statementBuilder = new SqlDbStatementBuilder();
            var queryBuilder     = new QueryBuilder <TestWithFieldMappingClass>();
            var queryGroup       = (QueryGroup)null;

            // Act
            var actual   = statementBuilder.CreateUpdate(queryBuilder, queryGroup);
            var expected = $"" +
                           $"UPDATE [TestWithFieldMappingClass] " +
                           $"SET [Field1] = @Field1, [Field2] = @Field2, [Field4] = @Field4 ;";

            // Assert
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 3
0
        public void TestWithExpression()
        {
            // Setup
            var statementBuilder = new SqlDbStatementBuilder();
            var queryBuilder     = new QueryBuilder <TestWithExpressionClass>();
            var queryGroup       = QueryGroup.Parse(new { Field1 = 1, Field4 = new { Operation = Operation.GreaterThan, Value = 2 } });

            // Act
            var actual   = statementBuilder.CreateUpdate(queryBuilder, queryGroup);
            var expected = $"" +
                           $"UPDATE [TestWithExpressionClass] " +
                           $"SET [Field2] = @Field2, [Field3] = @Field3 " +
                           $"WHERE ([Field1] = @_Field1 AND [Field4] > @_Field4) ;";

            // Assert
            Assert.AreEqual(expected, actual);
        }