Permalink
Browse files

fixed unit tests for default values

  • Loading branch information...
1 parent ccd300c commit c133a152d618325e60f2ea72e191eabd5c392715 @Pathoschild committed Dec 10, 2012
@@ -111,7 +111,7 @@ public void CanAlterDefaultConstraint()
"SET @sql = N'ALTER TABLE [TestTable1] DROP CONSTRAINT ' + @default;\r\n" +
"EXEC sp_executesql @sql;\r\n\r\n" +
"-- create alter table command to create new default constraint as string and run it\r\n" +
- "ALTER TABLE [TestTable1] WITH NOCHECK ADD CONSTRAINT DF_TestTable1_TestColumn1 DEFAULT(1) FOR [TestColumn1];";
+ "ALTER TABLE [TestTable1] WITH NOCHECK ADD CONSTRAINT [DF_TestTable1_TestColumn1] DEFAULT(1) FOR [TestColumn1];";
sql.ShouldBe(expected);
}
@@ -117,7 +117,7 @@ public override void CanCreateTableWithDefaultValue()
var expression = GeneratorTestHelper.GetCreateTableWithDefaultValue();
var sql = _generator.Generate(expression);
sql.ShouldBe(
- "CREATE TABLE [TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT DF_TestTable1_TestColumn1 DEFAULT 'Default', [TestColumn2] INT NOT NULL CONSTRAINT DF_TestTable1_TestColumn2 DEFAULT 0)");
+ "CREATE TABLE [TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT [DF_TestTable1_TestColumn1] DEFAULT 'Default', [TestColumn2] INT NOT NULL CONSTRAINT [DF_TestTable1_TestColumn2] DEFAULT 0)");
}
[Test]
@@ -128,7 +128,7 @@ public override void CanCreateTableWithDefaultValueExplicitlySetToNull()
expression.Columns[0].TableName = expression.TableName;
var sql = _generator.Generate(expression);
sql.ShouldBe(
- "CREATE TABLE [TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT DF_TestTable1_TestColumn1 DEFAULT NULL, [TestColumn2] INT NOT NULL)");
+ "CREATE TABLE [TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT [DF_TestTable1_TestColumn1] DEFAULT NULL, [TestColumn2] INT NOT NULL)");
}
[Test]
@@ -83,7 +83,7 @@ public void CanAlterDefaultConstraintWithDefaultSchema()
"SET @sql = N'ALTER TABLE [dbo].[TestTable1] DROP CONSTRAINT ' + @default;\r\n" +
"EXEC sp_executesql @sql;\r\n\r\n" +
"-- create alter table command to create new default constraint as string and run it\r\n" +
- "ALTER TABLE [dbo].[TestTable1] WITH NOCHECK ADD CONSTRAINT DF_TestTable1_TestColumn1 DEFAULT(1) FOR [TestColumn1];";
+ "ALTER TABLE [dbo].[TestTable1] WITH NOCHECK ADD CONSTRAINT [DF_TestTable1_TestColumn1] DEFAULT(1) FOR [TestColumn1];";
sql.ShouldBe(expected);
}
@@ -111,7 +111,7 @@ public void CanAlterDefaultConstraintWithCustomSchema()
"SET @sql = N'ALTER TABLE [TestSchema].[TestTable1] DROP CONSTRAINT ' + @default;\r\n" +
"EXEC sp_executesql @sql;\r\n\r\n" +
"-- create alter table command to create new default constraint as string and run it\r\n" +
- "ALTER TABLE [TestSchema].[TestTable1] WITH NOCHECK ADD CONSTRAINT DF_TestTable1_TestColumn1 DEFAULT(1) FOR [TestColumn1];";
+ "ALTER TABLE [TestSchema].[TestTable1] WITH NOCHECK ADD CONSTRAINT [DF_TestTable1_TestColumn1] DEFAULT(1) FOR [TestColumn1];";
sql.ShouldBe(expected);
}
@@ -139,7 +139,7 @@ public void CanCreateTableWithDefaultValueWithDefaultSchema()
var expression = GeneratorTestHelper.GetCreateTableWithDefaultValue();
var sql = generator.Generate(expression);
sql.ShouldBe(
- "CREATE TABLE [dbo].[TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT DF_TestTable1_TestColumn1 DEFAULT 'Default', [TestColumn2] INT NOT NULL CONSTRAINT DF_TestTable1_TestColumn2 DEFAULT 0)");
+ "CREATE TABLE [dbo].[TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT [DF_TestTable1_TestColumn1] DEFAULT 'Default', [TestColumn2] INT NOT NULL CONSTRAINT [DF_TestTable1_TestColumn2] DEFAULT 0)");
}
@@ -150,7 +150,7 @@ public void CanCreateTableWithDefaultValueWithCustomSchema()
expression.SchemaName = "TestSchema";
var sql = generator.Generate(expression);
sql.ShouldBe(
- "CREATE TABLE [TestSchema].[TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT DF_TestTable1_TestColumn1 DEFAULT 'Default', [TestColumn2] INT NOT NULL CONSTRAINT DF_TestTable1_TestColumn2 DEFAULT 0)");
+ "CREATE TABLE [TestSchema].[TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT [DF_TestTable1_TestColumn1] DEFAULT 'Default', [TestColumn2] INT NOT NULL CONSTRAINT [DF_TestTable1_TestColumn2] DEFAULT 0)");
}
@@ -162,7 +162,7 @@ public void CanCreateTableWithDefaultValueExplicitlySetToNullWithDefaultSchema()
expression.Columns[0].TableName = expression.TableName;
var sql = generator.Generate(expression);
sql.ShouldBe(
- "CREATE TABLE [dbo].[TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT DF_TestTable1_TestColumn1 DEFAULT NULL, [TestColumn2] INT NOT NULL)");
+ "CREATE TABLE [dbo].[TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT [DF_TestTable1_TestColumn1] DEFAULT NULL, [TestColumn2] INT NOT NULL)");
}
@@ -175,7 +175,7 @@ public void CanCreateTableWithDefaultValueExplicitlySetToNullWithCustomSchema()
expression.Columns[0].TableName = expression.TableName;
var sql = generator.Generate(expression);
sql.ShouldBe(
- "CREATE TABLE [TestSchema].[TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT DF_TestTable1_TestColumn1 DEFAULT NULL, [TestColumn2] INT NOT NULL)");
+ "CREATE TABLE [TestSchema].[TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT [DF_TestTable1_TestColumn1] DEFAULT NULL, [TestColumn2] INT NOT NULL)");
}
@@ -87,7 +87,7 @@ public void CanCreateTableWithDefaultValue()
var expression = GeneratorTestHelper.GetCreateTableWithDefaultValue();
var sql = generator.Generate(expression);
sql.ShouldBe(
- "CREATE TABLE [TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT DF_TestTable1_TestColumn1 DEFAULT 'Default', [TestColumn2] INT NOT NULL CONSTRAINT DF_TestTable1_TestColumn2 DEFAULT 0)");
+ "CREATE TABLE [TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT [DF_TestTable1_TestColumn1] DEFAULT 'Default', [TestColumn2] INT NOT NULL CONSTRAINT [DF_TestTable1_TestColumn2] DEFAULT 0)");
}
[Test]
@@ -98,7 +98,7 @@ public void CanCreateTableWithDefaultValueExplicitlySetToNull()
expression.Columns[0].TableName = expression.TableName;
var sql = generator.Generate(expression);
sql.ShouldBe(
- "CREATE TABLE [TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT DF_TestTable1_TestColumn1 DEFAULT NULL, [TestColumn2] INT NOT NULL)");
+ "CREATE TABLE [TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL CONSTRAINT [DF_TestTable1_TestColumn1] DEFAULT NULL, [TestColumn2] INT NOT NULL)");
}

0 comments on commit c133a15

Please sign in to comment.