public void ThrowExceptionOnSqlDbProviderCreateInlineInsertIfFieldsAreNull()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <ThrowExceptionOnSqlDbProviderCreateInlineInsertIfFieldsAreNullClass>();

            // Act/Assert
            statementBuilder.CreateInlineInsert(queryBuilder, null);
        }
        public void ThrowExceptionOnSqlDbProviderCreateInlineInsertIfAFieldIsMissingAtDataEntityMappings()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <ThrowExceptionOnSqlDbProviderCreateInlineInsertIfAFieldIsMissingAtDataEntityMappingsClass>();
            var fields           = Field.From(new[] { "Field1", "Field3" });

            // Act/Assert
            statementBuilder.CreateInlineInsert(queryBuilder, fields);
        }
예제 #3
0
        public void ThrowExceptionIfAFieldIsIgnoredAtInlineInsertOperation()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <ThrowExceptionIfAFieldIsIgnoredAtInlineInsertOperationClass>();
            var fields           = Field.From(new[] { "Field1", "Field2", "Field3" });

            // Act/Assert
            statementBuilder.CreateInlineInsert(queryBuilder, fields, false);
        }
예제 #4
0
        public void ThrowExceptionIfAtleastOneFieldIsMissingAtDataEntity()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <ThrowExceptionIfAtleastOneFieldIsMissingAtDataEntityClass>();
            var fields           = Field.From(new[] { "Field1", "Field3" });

            // Act/Assert
            statementBuilder.CreateInlineInsert(queryBuilder, fields, false);
        }
        public void TestSqlDbProviderCreateInlineInsertWithFieldMappings()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <TestSqlDbProviderCreateInlineInsertWithFieldMappingsClass>();
            var fields           = Field.From(new[] { "Field1", "Field2", "Field4" });

            // Act
            var actual   = statementBuilder.CreateInlineInsert(queryBuilder, fields);
            var expected = $"" +
                           $"INSERT INTO [ClassName] " +
                           $"( [Field1], [Field2], [Field4] ) " +
                           $"VALUES " +
                           $"( @Field1, @Field2, @Field4 ) ; " +
                           $"SELECT NULL AS [Result] ;";

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void TestSqlDbProviderCreateInlineInsertWithPrimaryIdentity()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <TestSqlDbProviderCreateInlineInsertWithPrimaryIdentityClass>();
            var fields           = Field.From(new[] { "Field1", "Field2", "Field3" });

            // Act
            var actual   = statementBuilder.CreateInlineInsert(queryBuilder, fields);
            var expected = $"" +
                           $"INSERT INTO [TestSqlDbProviderCreateInlineInsertWithPrimaryIdentityClass] " +
                           $"( [Field2], [Field3] ) " +
                           $"VALUES " +
                           $"( @Field2, @Field3 ) ; " +
                           $"SELECT SCOPE_IDENTITY() AS [Result] ;";

            // Assert
            Assert.AreEqual(expected, actual);
        }
예제 #7
0
        public void TestOverrideIgnoreFromInlineInsertOperation()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <TestOverrideIgnoreFromInlineInsertOperationClass>();
            var fields           = Field.From(new[] { "Field1", "Field2", "Field3" });

            // Act
            var actual   = statementBuilder.CreateInlineInsert(queryBuilder, fields, true);
            var expected = $"" +
                           $"INSERT INTO [ClassName] " +
                           $"( [Field1], [Field2], [Field3] ) " +
                           $"VALUES " +
                           $"( @Field1, @Field2, @Field3 ) ; " +
                           $"SELECT NULL AS [Result] ;";

            // Assert
            Assert.AreEqual(expected, actual);
        }
예제 #8
0
        public void TestWithPrimaryKeyFromAttribute()
        {
            // Setup
            var statementBuilder = new SqlStatementBuilder();
            var queryBuilder     = new QueryBuilder <TestWithPrimaryKeyFromAttributeClass>();
            var fields           = Field.From(new[] { "Field2", "Field3" });

            // Act
            var actual   = statementBuilder.CreateInlineInsert(queryBuilder, fields, false);
            var expected = $"" +
                           $"INSERT INTO [ClassName] " +
                           $"( [Field2], [Field3] ) " +
                           $"VALUES " +
                           $"( @Field2, @Field3 ) ; " +
                           $"SELECT @Field1 AS [Result] ;";

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