public void ShouldGetTableDefinitionFromTableName() { var tableA = ObjectMetadata.FromQualifiedString("msdb.[dbo].[syscategories]"); ObjectMetadataAccess da = new ObjectMetadataAccess(GetLocalConnection()); var token = new CancellationTokenSource().Token; var actual = da.SelectTopNFrom(tableA, token); Assert.That(actual.Columns.Count, Is.EqualTo(4)); }
public static string MockTableWithRows(CancellationToken token, MockOptionsDictionary options, int numRows, ObjectMetadata tableMeta, string connectionString) { StringBuilder sb = new StringBuilder(); ObjectMetadataAccess da = new ObjectMetadataAccess(connectionString); var table = da.SelectTopNFrom(tableMeta, token, numRows); sb.Append(TsqltManager.FakeTable(tableMeta)); sb.AppendLine(); sb.Append(TsqltManager.GenerateInsertFor(table, tableMeta, options.EachColumnInSelectOnNewRow, options.EachColumnInValuesOnNewRow)); return(sb.ToString()); }
public void ShouldGenerateInsertIntoMockTable() { var meta = ObjectMetadata.FromQualifiedString("msdb.[dbo].[syscategories]"); ObjectMetadataAccess da = new ObjectMetadataAccess(GetLocalConnection()); var token = new CancellationTokenSource().Token; var table = da.SelectTopNFrom(meta, token); var actual = TsqltManager.GenerateInsertFor(table, meta); var expected = @"INSERT INTO [msdb].[dbo].[syscategories] ( [category_id], [category_class], [category_type], [name] ) " + "VALUES\t(0, 1, 1, '[Uncategorized (Local)]');"; Console.WriteLine(expected); Console.WriteLine(actual); Assert.That(actual, Is.EqualTo(expected)); }