public void ReadXmlSchema_ByXmlReader()
{
DataSet ds1 = new DataSet();
ds1.Tables.Add(DataProvider.CreateParentDataTable());
ds1.Tables.Add(DataProvider.CreateChildDataTable());
StringWriter sw1 = new StringWriter();
XmlTextWriter xmlTW1 = new XmlTextWriter(sw1);
StringWriter sw2 = new StringWriter();
XmlTextWriter xmlTW2 = new XmlTextWriter(sw2);
//write xml file, schema only
ds1.Tables[0].WriteXmlSchema(xmlTW1);
xmlTW1.Flush();
ds1.Tables[1].WriteXmlSchema(xmlTW2);
xmlTW2.Flush();
StringReader sr1 = new StringReader(sw1.ToString());
XmlTextReader xmlTR1 = new XmlTextReader(sr1);
StringReader sr2 = new StringReader(sw2.ToString());
XmlTextReader xmlTR2 = new XmlTextReader(sr2);
//copy both data and schema
//DataSet ds2 = new DataSet ();
DataTable dt1 = new DataTable();
DataTable dt2 = new DataTable();
//ds2.ReadXmlSchema (xmlTR);
dt1.ReadXmlSchema(xmlTR1);
dt2.ReadXmlSchema(xmlTR2);
//check xml schema
// ReadXmlSchema - Tables count
//Assert.Equal (ds2.Tables.Count, ds1.Tables.Count);
// ReadXmlSchema - Tables 0 Col count
Assert.Equal(ds1.Tables[0].Columns.Count, dt1.Columns.Count);
// ReadXmlSchema - Tables 1 Col count
Assert.Equal(ds1.Tables[1].Columns.Count, dt2.Columns.Count);
//check some colummns types
// ReadXmlSchema - Tables 0 Col type
Assert.Equal(ds1.Tables[0].Columns[0].GetType(), dt1.Columns[0].GetType());
// ReadXmlSchema - Tables 1 Col type
Assert.Equal(ds1.Tables[1].Columns[3].GetType(), dt2.Columns[3].GetType());
//check that no data exists
// ReadXmlSchema - Table 1 row count
Assert.Equal(0, dt1.Rows.Count);
// ReadXmlSchema - Table 2 row count
Assert.Equal(0, dt2.Rows.Count);
}