[Test]
//[Category ("NotWorking")]
public void ReadWriteXmlSchema_IgnoreSchema () {
DataSet ds = new DataSet ();
ds.ReadXmlSchema ("Test/System.Data/store.xsd");
// check dataset properties before testing write
AssertDataSet ("ds", ds, "NewDataSet", 3, 2);
AssertDataTable ("tab1", ds.Tables[0], "bookstore", 1, 0, 0, 1, 1, 1);
AssertDataTable ("tab2", ds.Tables[1], "book", 5, 0, 1, 1, 2, 1);
AssertDataTable ("tab3", ds.Tables[2], "author", 3, 0, 1, 0, 1, 0);
// FIXME: currently order is not compatible. Use name as index
AssertDataRelation ("rel1", ds.Relations["book_author"], "book_author", true, new string[] { "book_Id" }, new string[] { "book_Id" }, true, true);
AssertDataRelation ("rel2", ds.Relations["bookstore_book"], "bookstore_book", true, new string[] { "bookstore_Id" }, new string[] { "bookstore_Id" }, true, true);
ds.ReadXml ("Test/System.Data/region.xml", XmlReadMode.IgnoreSchema);
ds.Relations.Clear (); // because can not call WriteXmlSchema with nested relations.
TextWriter writer1 = new StringWriter ();
ds.Tables[0].WriteXmlSchema (writer1);
//string TextString1 = GetNormalizedSchema (writer1.ToString ());
string TextString1 = writer1.ToString ();
string expected1 = @"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"";
Console.WriteLine ("{0} - {1}", TextString1, expected1);
AssertEquals ("#1", expected1, TextString1.Replace ("\r\n", "").Replace (" ", "").Replace ("\n", ""));
TextWriter writer2 = new StringWriter ();
ds.Tables[1].WriteXmlSchema (writer2, false);
string TextString2 = GetNormalizedSchema (writer2.ToString ());
string expected2 = @"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"";
AssertEquals ("#2", expected2, TextString2.Replace ("\r\n", "").Replace (" ", ""));
TextWriter writer3 = new StringWriter ();
ds.Tables[2].WriteXmlSchema (writer3);
string TextString3 = GetNormalizedSchema (writer3.ToString ());
string expected3 = @"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"";
AssertEquals ("#3", expected3, TextString3.Replace ("\r\n", "").Replace (" ", ""));
TextWriter writer4 = new StringWriter ();
string expStr = "";
try {
ds.Tables[3].WriteXmlSchema (writer4);
}
catch (Exception ex) {
expStr = ex.Message;
}
AssertEquals ("#4", "Cannot find table 3.", expStr);
}