[Test]
//[Category ("NotWorking")]
// WriteXmlSchema doesn't have overload wityh 2 parameters in System.Data
// and is commented-out TWICE below
public void ReadWriteXmlSchema () {
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.InferSchema);
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 expected1 = @"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"";
AssertEquals ("#1", expected1.Replace ("\n", ""), 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 ();
ds.Tables[3].WriteXmlSchema (writer4);
string TextString4 = GetNormalizedSchema (writer4.ToString ());
string expected4 = @"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"" +
@"";
AssertEquals ("#4", expected4, TextString4.Replace ("\r\n", "").Replace (" ", ""));
}