Пример #1
0
        public void GenerateInsertQuery_ColumnHasDefaultConstraintAndNonDefaultValue_Valid()
        {
            // Arrange
            var generator = new SqlQueryGenerator <HasDefaultConstraintEntity>("dbo", "Users");
            var record    = new HasDefaultConstraintEntity
            {
                Id          = 42,
                DateCreated = DateTime.Now
            };

            // Act
            var query = generator.GenerateInsertQuery(record);

            // Assert
            Assert.Equal("INSERT INTO [dbo].[Users] ([Id], [DateCreated]) OUTPUT [inserted].[Id], [inserted].[DateCreated] VALUES (@Id, @DateCreated);", query);
        }
Пример #2
0
        public void GenerateInsertQuery_ColumnHasDefaultConstraintAndNonDefaultValue_Valid()
        {
            // Arrange
            var generator = new MySqlQueryGenerator <HasDefaultConstraintEntity>("Users");
            var record    = new HasDefaultConstraintEntity
            {
                Id          = 42,
                DateCreated = DateTime.Now
            };

            // Act
            var query = generator.GenerateInsertQuery(record);

            // Assert
            Assert.Equal(@"INSERT INTO Users (Id, DateCreated) VALUES (@Id, @DateCreated);
SELECT Users.Id, Users.DateCreated FROM Users WHERE Users.Id = @Id;", query);
        }