public void ShouldWriteQueryForAddTableWithFileTableFalse() { var schemaName = "schemaName"; var tableName = "tableName"; var column1 = Column.VarChar("name", new CharacterLength(50), null, Nullable.NotNull, "''", "default constraint name", "varchar column"); Identity identity = new Identity(); var column2 = Column.Int("int column", identity, "test int column"); Column[] columnlist = new Column[] { column1, column2 }; bool fileTable = false; var fileGroup = "fileGroup"; var textImageFileGroup = "textImageFileGroup"; var fileStremFileGroup = "fileGroup"; string[] options = new string[] { "option1", "option2" }; var op = new AddTableOperation(schemaName, tableName, columnlist, fileTable, fileGroup, textImageFileGroup, fileStremFileGroup, options); var expectedQuery = $@"create table [schemaName].[tableName] ({Environment.NewLine}" + $" [name] varchar(50) not null constraint [default constraint name] default '',{Environment.NewLine}" + $" [int column] int identity not null{Environment.NewLine})" + $"{Environment.NewLine}" + $"on fileGroup{Environment.NewLine}" + $"textimage_on textImageFileGroup{Environment.NewLine}" + $"filestream_on fileGroup{Environment.NewLine}" + "with ( option1, option2 )"; Assert.That(op.ToQuery(), Is.EqualTo(expectedQuery)); }
public void ShouldFormatOneColumnTable() { var schemaName = "schemaName"; var tableName = "tableName"; var column1 = Column.VarChar("name", new CharacterLength(50), null, Nullable.NotNull, "''", "default constraint name", "varchar column"); Column[] columnlist = { column1 }; var op = new AddTableOperation(schemaName, tableName, columnlist, false, null, null, null, null); var expectedQuery = $@"create table [schemaName].[tableName] ({Environment.NewLine}" + $" [name] varchar(50) not null constraint [default constraint name] default ''{Environment.NewLine})"; Assert.That(op.ToQuery(), Is.EqualTo(expectedQuery)); }
public void ShouldWriteQueryForAddTableWithAllOptionsTrue() { var schemaName = "schemaName"; var tableName = "tableName"; var column1 = Column.VarChar("name", new CharacterLength(50), null, Nullable.NotNull, "''", "default constraint name", "varchar column"); Identity identity = new Identity(); var column2 = Column.Int("int column", identity, "test int column"); Column[] columnlist = new Column[] { column1, column2 }; bool fileTable = true; var fileGroup = "fileGroup"; var textImageFileGroup = "textImageFileGroup"; var fileStremFileGroup = "fileGroup"; string[] options = new string[] { "option1", "option2" }; var op = new AddTableOperation(schemaName, tableName, columnlist, fileTable, fileGroup, textImageFileGroup, fileStremFileGroup, options); var expectedQuery = String.Format(@"create table [schemaName].[tableName] as FileTable{0}on fileGroup{0}textimage_on textImageFileGroup{0}filestream_on fileGroup{0}with ( option1, option2 )", Environment.NewLine); Assert.That(op.ToQuery(), Is.EqualTo(expectedQuery)); }
public void ShouldWriteQueryForAddTableWithNoOptions() { var schemaName = "schemaName"; var tableName = "tableName"; var column1 = Column.VarChar("name", new CharacterLength(50), null, Nullable.NotNull, "''", "default constraint name", "varchar column"); Identity identity = new Identity(); var column2 = Column.Int("int column", identity, "test int column"); Column[] columnlist = new Column[] { column1, column2 }; bool fileTable = true; var fileGroup = ""; var textImageFileGroup = ""; var fileStremFileGroup = ""; string[] options = new string[] { }; var op = new AddTableOperation(schemaName, tableName, columnlist, fileTable, fileGroup, textImageFileGroup, fileStremFileGroup, options); var expectedQuery = @"create table [schemaName].[tableName] as FileTable"; Assert.That(op.ToQuery(), Is.EqualTo(expectedQuery)); }