rendered paste body void fillRestrictionTable(DataTable restrictionTable, String collectionName,
String restrictionName, String parameterName,
String restrictionDefault, Int32 restrictionNumber)
{
DataRow row = restrictionTable.NewRow();
row["CollectionName"] = collectionName;
row["RestrictionName"] = restrictionName;
row["ParameterName"] = parameterName;
row["RestrictionDefault"] = restrictionDefault;
row["RestrictionNumber"] = restrictionNumber;
restrictionTable.Rows.Add(row);
}
[Test]
public void GetSchemaTest26()
{
DataTable restrictionTable = new DataTable("Restrictions");
restrictionTable.Columns.Add("CollectionName", typeof (String));
restrictionTable.Columns.Add("RestrictionName", typeof(String));
restrictionTable.Columns.Add("ParameterName", typeof(String));
restrictionTable.Columns.Add("RestrictionDefault", typeof(String));
restrictionTable.Columns.Add("RestrictionNumber", typeof(Int32));
DataRow row = restrictionTable.NewRow();
fillRestrictionTable(restrictionTable, "Users", "User_Name", "@Name", "name", 1);
fillRestrictionTable(restrictionTable, "Databases", "Name", "@Name", "Name", 1);
fillRestrictionTable(restrictionTable, "Tables", "Catalog", "@Catalog", "TABLE_CATALOG", 1);
fillRestrictionTable(restrictionTable, "Tables", "Owner", "@Owner", "TABLE_SCHEMA", 2);
fillRestrictionTable(restrictionTable, "Tables", "Table", "@Name", "TABLE_NAME", 3);
fillRestrictionTable(restrictionTable, "Tables", "TableType", "@TableType", "TABLE_TYPE", 4);
fillRestrictionTable(restrictionTable, "Columns", "Catalog", "@Catalog", "TABLE_CATALOG", 1);
fillRestrictionTable(restrictionTable, "Columns", "Owner", "@Owner", "TABLE_SCHEMA", 2);
fillRestrictionTable(restrictionTable, "Columns", "Table", "@Table", "TABLE_NAME", 3);
fillRestrictionTable(restrictionTable, "Columns", "Column", "@Column", "COLUMN_NAME", 4);
fillRestrictionTable(restrictionTable, "Views", "Catalog", "@Catalog", "TABLE_CATALOG", 1);
fillRestrictionTable(restrictionTable, "Views", "Owner", "@Owner", "TABLE_SCHEMA", 2);
fillRestrictionTable(restrictionTable, "Views", "Table", "@Table", "TABLE_NAME", 3);
fillRestrictionTable(restrictionTable, "ViewColumns", "Catalog", "@Catalog", "VIEW_CATALOG", 1);
fillRestrictionTable(restrictionTable, "ViewColumns", "Owner", "@Owner", "VIEW_SCHEMA", 2);
fillRestrictionTable(restrictionTable, "ViewColumns", "Table", "@Table", "VIEW_NAME", 3);
fillRestrictionTable(restrictionTable, "ViewColumns", "Column", "@Column", "COLUMN_NAME", 4);
fillRestrictionTable(restrictionTable, "ProcedureParameters", "Catalog", "@Catalog", "SPECIFIC_CATALOG", 1);
fillRestrictionTable(restrictionTable, "ProcedureParameters", "Owner", "@Owner", "SPECIFIC_SCHEMA", 2);
fillRestrictionTable(restrictionTable, "ProcedureParameters", "Name", "@Name", "SPECIFIC_NAME", 3);
fillRestrictionTable(restrictionTable, "ProcedureParameters", "Parameter", "@Parameter", "PARAMETER_NAME", 4);
fillRestrictionTable(restrictionTable, "Procedures", "Catalog", "@Catalog", "SPECIFIC_CATALOG", 1);
fillRestrictionTable(restrictionTable, "Procedures", "Owner", "@Owner", "SPECIFIC_SCHEMA", 2);
fillRestrictionTable(restrictionTable, "Procedures", "Name", "@Name", "SPECIFIC_NAME", 3);
fillRestrictionTable(restrictionTable, "Procedures", "Type", "@Type", "ROUTINE_TYPE", 4);
fillRestrictionTable(restrictionTable, "IndexColumns", "Catalog", "@Catalog", "db_name()", 1);
fillRestrictionTable(restrictionTable, "IndexColumns", "Owner", "@Owner", "user_name()", 2);
fillRestrictionTable(restrictionTable, "IndexColumns", "Table", "@Table", "o.name", 3);
fillRestrictionTable(restrictionTable, "IndexColumns", "ConstraintName", "@ConstraintName", "x.name", 4);
fillRestrictionTable(restrictionTable, "IndexColumns", "Column", "@Column", "c.name", 5);
fillRestrictionTable(restrictionTable, "Indexes", "Catalog", "@Catalog", "db_name()", 1);
fillRestrictionTable(restrictionTable, "Indexes", "Owner", "@Owner", "user_name()", 2);
fillRestrictionTable(restrictionTable, "Indexes", "Table", "@Table", "o.name", 3);
fillRestrictionTable(restrictionTable, "Indexes", "Name", "@Name", "x.name", 4);
fillRestrictionTable(restrictionTable, "UserDefinedTypes", "assembly_name", "@AssemblyName", "assemblies.name", 1);
fillRestrictionTable(restrictionTable, "UserDefinedTypes", "udt_name", "@UDTName", "types.assembly_class", 2);
fillRestrictionTable(restrictionTable, "ForeignKeys", "Catalog", "@Catalog", "CONSTRAINT_CATALOG", 1);
fillRestrictionTable(restrictionTable, "ForeignKeys", "Owner", "@Owner", "CONSTRAINT_SCHEMA", 2);
fillRestrictionTable(restrictionTable, "ForeignKeys", "Table", "@Table", "TABLE_NAME", 3);
fillRestrictionTable(restrictionTable, "ForeignKeys", "Name", "@Name", "CONSTRAINT_NAME", 4);
foreach (DataRow drow in restrictionTable.Rows)
{
foreach (DataColumn col in restrictionTable.Columns)
{
Console.WriteLine("{0} - {1}", col.ColumnName, drow[col]);
}
}
}
void fillGetSchemaTable(DataTable getSchemaTable, string collectionName,
Int32 numberOfRestrictions, Int32 numberOfIdentifierParts)
{
DataRow row = getSchemaTable.NewRow();
row["CollectionName"] = collectionName;
row["NumberOfRestrictions"] = numberOfRestrictions;
row["NumberOfIdentifierParts"] = numberOfIdentifierParts;
getSchemaTable.Rows.Add(row);
}
[Test]
public void GetSchemaTest27()
{
DataTable getSchemaTable = new DataTable("GetSchema");
getSchemaTable.Columns.Add("CollectionName", typeof(String));
getSchemaTable.Columns.Add("NumberOfRestrictions", typeof(Int32));
getSchemaTable.Columns.Add("NumberOfIdentifierParts", typeof(Int32));
fillGetSchemaTable (getSchemaTable, "MetaDataCollections", 0, 0);
fillGetSchemaTable(getSchemaTable, "DataSourceInformation", 0, 0);
fillGetSchemaTable(getSchemaTable, "DataTypes", 0, 0);
fillGetSchemaTable(getSchemaTable, "Restrictions", 0, 0);
fillGetSchemaTable(getSchemaTable, "ReservedWords", 0, 0);
fillGetSchemaTable(getSchemaTable, "Users", 1, 1);
fillGetSchemaTable(getSchemaTable, "Databases", 1, 1);
fillGetSchemaTable(getSchemaTable, "Tables", 4, 3);
fillGetSchemaTable(getSchemaTable, "Columns", 4, 4);
fillGetSchemaTable(getSchemaTable, "Views", 3, 3);
fillGetSchemaTable(getSchemaTable, "ViewColumns", 4, 4);
fillGetSchemaTable(getSchemaTable, "ProcedureParameters", 4, 1);
fillGetSchemaTable(getSchemaTable, "Procedures", 4, 3);
fillGetSchemaTable(getSchemaTable, "ForeignKeys", 4, 3);
fillGetSchemaTable(getSchemaTable, "IndexColumns", 5, 4);
fillGetSchemaTable(getSchemaTable, "Indexes", 4, 3);
fillGetSchemaTable(getSchemaTable, "UserDefinedTypes", 2, 1);
foreach (DataRow drow in getSchemaTable.Rows)
{
foreach (DataColumn col in getSchemaTable.Columns)
{
Console.WriteLine("{0} - {1}", col.ColumnName, drow[col]);
}
}
}