Ejemplo n.º 1
0
        public void ThrowExceptionOnSqlDbProviderCreateInlineUpdateIfTheTargetFieldsAreNull()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <ThrowExceptionOnSqlDbProviderCreateInlineUpdateIfTheTargetFieldsAreNullClass>();

            // Act/Assert
            statementBuilder.CreateInlineUpdate(queryBuilder, null, null);
        }
Ejemplo n.º 2
0
        public void ThrowExceptionOnSqlDbProviderCreateInlineUpdateIfTheIdentityFieldIsNotThePrimaryField()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <ThrowExceptionOnSqlDbProviderCreateInlineUpdateIfTheIdentityFieldIsNotThePrimaryFieldClass>();
            var fields           = Field.From(new[] { "Field1" });

            // Act/Assert
            statementBuilder.CreateInlineUpdate(queryBuilder, fields, null);
        }
Ejemplo n.º 3
0
        public void ThrowExceptionOnSqlDbProviderCreateInlineUpdateIfTheTargetFieldIsAnIdentity()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <ThrowExceptionOnSqlDbProviderCreateInlineUpdateIfTheTargetFieldIsAnIdentityClass>();
            var fields           = Field.From(new[] { "Field1", "Field2", "Field3" });

            // Act/Assert
            statementBuilder.CreateInlineUpdate(queryBuilder, fields, null);
        }
Ejemplo n.º 4
0
        public void ThrowExceptionIfTheTargetFieldIsTheId()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <ThrowExceptionIfTheTargetFieldIsTheIdClass>();
            var fields           = Field.From(new[] { "Id", "Field2", "Field3" });

            // Act/Assert
            statementBuilder.CreateInlineUpdate(queryBuilder, fields, null);
        }
Ejemplo n.º 5
0
        public void ThrowExceptionIfTheTargetFieldMappingIsDifferentAtDataEntity()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <ThrowExceptionIfTheTargetFieldMappingIsDifferentAtDataEntityClass>();
            var fields           = Field.From(new[] { "Field1", "Field2", "Field3" });

            // Act/Assert
            statementBuilder.CreateInlineUpdate(queryBuilder, fields, null);
        }
Ejemplo n.º 6
0
        public void TestSqlDbProviderCreateInlineUpdateWithFieldMappings()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <TestSqlDbProviderCreateInlineUpdateWithFieldMappingsClass>();
            var fields           = Field.From(new[] { "Field1", "Field2", "Field4" });

            // Act
            var actual   = statementBuilder.CreateInlineUpdate(queryBuilder, fields, null);
            var expected = $"" +
                           $"UPDATE [ClassName] " +
                           $"SET [Field1] = @Field1, " +
                           $"[Field2] = @Field2, " +
                           $"[Field4] = @Field4 ;";

            // Assert
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 7
0
        public void TestSqlDbProviderCreateInlineUpdateWithFieldMappingsAndExpressions()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <TestSqlDbProviderCreateInlineUpdateWithFieldMappingsAndExpressionsClass>();
            var fields           = Field.From(new[] { "Field1", "Field2", "Field4" });
            var expression       = new { Field1 = 1 };
            var queryGroup       = QueryGroup.Parse(expression);

            // Act
            var actual   = statementBuilder.CreateInlineUpdate(queryBuilder, fields, queryGroup);
            var expected = $"" +
                           $"UPDATE [TestSqlDbProviderCreateInlineUpdateWithFieldMappingsAndExpressionsClass] " +
                           $"SET [Field1] = @Field1, " +
                           $"[Field2] = @Field2, " +
                           $"[Field4] = @Field4 " +
                           $"WHERE ([Field1] = @_Field1) ;";

            // Assert
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 8
0
        public void TestOverrideIgnoreForUpdate()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <TestOverrideIgnoreForUpdateClass>();
            var fields           = Field.From(new[] { "Field1", "Field2", "Field3" });
            var expression       = new { Field1 = 1 };
            var queryGroup       = QueryGroup.Parse(expression);

            // Act
            var actual   = statementBuilder.CreateInlineUpdate(queryBuilder, fields, queryGroup, true);
            var expected = $"" +
                           $"UPDATE [TestOverrideIgnoreForUpdateClass] " +
                           $"SET [Field1] = @Field1, " +
                           $"[Field2] = @Field2, " +
                           $"[Field3] = @Field3 " +
                           $"WHERE ([Field1] = @_Field1) ;";

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