public void WhenColumnWithNotNull_GetCorrespondingTableScript() { var table = new Table("TestTables"); table.AddColumn("MyColumn", new Int()).NotNull(); var createScript = table.GetUpScript().Single(); Assert.Equal("CREATE TABLE TestTables\r\n(\r\nMyColumn int NOT NULL\r\n)", createScript); }
public void WhenCreateTableWithNotNullAndPrimaryKey_GetCorrespondingTableScript() { var table = new Table("TestTables"); table.AddColumn("MyIdColumn", new Int()).PrimaryKey(); table.AddColumn("MyValue", new NVarChar(100)); var createScript = table.GetUpScript().Single(); Assert.Equal("CREATE TABLE TestTables\r\n(\r\nMyIdColumn int NOT NULL PRIMARY KEY,\r\nMyValue nvarchar(100)\r\n)", createScript); }
public void WhenCreateTableWithNamedPrimaryKey_GetCorrespondingTableScript() { var table = new Table("TestTables"); table.AddColumn("Key1", new Int()).PrimaryKey("PrimaryKeyForTestTables"); table.AddColumn("Key2", new Int()).PrimaryKey("PrimaryKeyForTestTables"); var createScript = table.GetUpScript().Single(); Assert.Equal("CREATE TABLE TestTables\r\n(\r\nKey1 int NOT NULL,\r\nKey2 int NOT NULL,\r\nCONSTRAINT PrimaryKeyForTestTables PRIMARY KEY (Key1,Key2)\r\n)", createScript); }
public void WhenCreateTableWithAutoIncrementAsNoPrimaryKey_GetCorrespondingTableScript() { var table = new Table("TestTables"); table.AddColumn("MyIdColumn", new Int()).AutoIncrement(primaryKey: false); table.AddColumn("MyValue", new NVarChar(100)); var createScript = table.GetUpScript().Single(); Assert.Equal("CREATE TABLE TestTables\r\n(\r\nMyIdColumn int IDENTITY(1,1),\r\nMyValue nvarchar(100)\r\n)", createScript); }
public void WhenCreateTableWithNamedUniquesAndOneUniqueColumn_GetCorrespondingTableScript() { var table = new Table("TestTables"); table.AddColumn("Col1", new Int()).Unique("PrimaryKeyForTestTables"); table.AddColumn("Col2", new Int()).Unique("PrimaryKeyForTestTables"); table.AddColumn("Col3", new Int()).Unique(); var createScript = table.GetUpScript().Single(); Assert.Equal("CREATE TABLE TestTables\r\n(\r\nCol1 int,\r\nCol2 int,\r\nCol3 int UNIQUE,\r\nCONSTRAINT PrimaryKeyForTestTables UNIQUE (Col1,Col2)\r\n)", createScript); }
public void WhenGuidColumn_GetCorrespondingTableScript() { var table = new Table("TestTables"); table.AddColumn("MyColumn", new Guid()).NotNull(); var createScript = table.GetUpScript().Single(); Assert.Equal("CREATE TABLE TestTables\r\n(\r\nMyColumn uniqueidentifier NOT NULL\r\n)", createScript); }