// Author:\r
// Atsushi Enomoto <atsushi@ximian.com>\r
//\r
-// (C)2004 Novell Inc.\r
-//\r
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+\r
\r
using System;\r
using System.IO;\r
using System.Data;\r
using System.Text;\r
using System.Xml;\r
+using System.Xml.Serialization;\r
using NUnit.Framework;\r
\r
namespace MonoTests.System.Data\r
{\r
[TestFixture]\r
- public class DataSetReadXmlTest : Assertion\r
+ public class DataSetReadXmlTest : DataSetAssertion\r
{\r
\r
const string xml1 = "";\r
const string xml6 = "<root><test>1</test></root>";\r
const string xml7 = "<root><test>1</test><test2>a</test2></root>";\r
const string xml8 = "<dataset><table><col1>foo</col1><col2>bar</col2></table></dataset>";\r
+ const string xml29 = @"<PersonalSite><License Name='Sum Wang' Email='sumwang@somewhere.net' Mode='Trial' StartDate='01/01/2004' Serial='aaa' /></PersonalSite>";\r
\r
const string diff1 = @"<diffgr:diffgram xmlns:msdata='urn:schemas-microsoft-com:xml-msdata' xmlns:diffgr='urn:schemas-microsoft-com:xml-diffgram-v1'>\r
<NewDataSet>\r
</xs:schema>";\r
const string schema2 = schema1 + xml8;\r
\r
- private void AssertDataSet (string label, DataSet ds, string name, int tableCount)\r
- {\r
- AssertEquals (label + ".DataSetName", name, ds.DataSetName);\r
- AssertEquals (label + ".TableCount", tableCount, ds.Tables.Count);\r
- }\r
-\r
- private void AssertDataTable (DataTable dt, string name, int columnCount, int rowCount)\r
- {\r
- AssertEquals ("TableName", name, dt.TableName);\r
- AssertEquals ("ColumnCount", columnCount, dt.Columns.Count);\r
- AssertEquals ("RowCount", rowCount, dt.Rows.Count);\r
- }\r
-\r
- private void AssertReadXml (DataSet ds, string label, string xml, XmlReadMode readMode, XmlReadMode resultMode, string datasetName, int tableCount)\r
- {\r
- AssertReadXml (ds, label, xml, readMode, resultMode, datasetName, tableCount, ReadState.EndOfFile);\r
- }\r
-\r
- // a bit detailed version\r
- private void AssertReadXml (DataSet ds, string label, string xml, XmlReadMode readMode, XmlReadMode resultMode, string datasetName, int tableCount, ReadState state)\r
- {\r
- XmlReader xtr = new XmlTextReader (xml, XmlNodeType.Element, null);\r
- AssertEquals (label + ".return", resultMode, ds.ReadXml (xtr, readMode));\r
- AssertDataSet (label + ".dataset", ds, datasetName, tableCount);\r
- AssertEquals (label + ".readstate", state, xtr.ReadState);\r
- }\r
-\r
[Test]\r
public void ReadSimpleAuto ()\r
{\r
- DataSet ds = new DataSet ();\r
+ DataSet ds;\r
\r
// empty XML\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "EmptyString", xml1,\r
XmlReadMode.Auto, XmlReadMode.Auto,\r
"NewDataSet", 0);\r
\r
// simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "EmptyElement", xml2,\r
XmlReadMode.Auto, XmlReadMode.InferSchema,\r
- "NewDataSet", 0);\r
+ "root", 0);\r
\r
// simple element2\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "StartEndTag", xml3,\r
XmlReadMode.Auto, XmlReadMode.InferSchema,\r
- "NewDataSet", 0);\r
+ "root", 0);\r
\r
// whitespace in simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "Whitespace", xml4,\r
XmlReadMode.Auto, XmlReadMode.InferSchema,\r
- "NewDataSet", 0);\r
+ "root", 0);\r
\r
// text in simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SingleText", xml5,\r
XmlReadMode.Auto, XmlReadMode.InferSchema,\r
- "NewDataSet", 0);\r
+ "root", 0);\r
\r
// simple table pattern:\r
// root becomes a table and test becomes a column.\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleTable", xml6,\r
XmlReadMode.Auto, XmlReadMode.InferSchema,\r
"NewDataSet", 1);\r
- AssertDataTable (ds.Tables [0], "root", 1, 1);\r
+ AssertDataTable ("xml6", ds.Tables [0], "root", 1, 1, 0, 0, 0, 0);\r
\r
// simple table with 2 columns:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleTable2", xml7,\r
XmlReadMode.Auto, XmlReadMode.InferSchema,\r
"NewDataSet", 1);\r
- AssertDataTable (ds.Tables [0], "root", 2, 1);\r
+ AssertDataTable ("xml7", ds.Tables [0], "root", 2, 1, 0, 0, 0, 0);\r
\r
// simple dataset with 1 table:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleDataSet", xml8,\r
XmlReadMode.Auto, XmlReadMode.InferSchema,\r
"dataset", 1);\r
- AssertDataTable (ds.Tables [0], "table", 2, 1);\r
+ AssertDataTable ("xml8", ds.Tables [0], "table", 2, 1, 0, 0, 0, 0);\r
}\r
\r
[Test]\r
public void ReadSimpleDiffgram ()\r
{\r
- DataSet ds = new DataSet ();\r
+ DataSet ds;\r
\r
// empty XML\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "EmptyString", xml1,\r
XmlReadMode.DiffGram, XmlReadMode.DiffGram,\r
"NewDataSet", 0);\r
\r
// simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "EmptyElement", xml2,\r
XmlReadMode.DiffGram, XmlReadMode.DiffGram,\r
"NewDataSet", 0);\r
\r
// simple element2\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "StartEndTag", xml3,\r
XmlReadMode.DiffGram, XmlReadMode.DiffGram,\r
"NewDataSet", 0);\r
\r
// whitespace in simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "Whitespace", xml4,\r
XmlReadMode.DiffGram, XmlReadMode.DiffGram,\r
"NewDataSet", 0);\r
\r
// text in simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SingleText", xml5,\r
XmlReadMode.DiffGram, XmlReadMode.DiffGram,\r
"NewDataSet", 0);\r
\r
// simple table pattern:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleTable", xml6,\r
XmlReadMode.DiffGram, XmlReadMode.DiffGram,\r
"NewDataSet", 0);\r
\r
// simple table with 2 columns:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleTable2", xml7,\r
XmlReadMode.DiffGram, XmlReadMode.DiffGram,\r
"NewDataSet", 0);\r
\r
// simple dataset with 1 table:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleDataSet", xml8,\r
XmlReadMode.DiffGram, XmlReadMode.DiffGram,\r
"NewDataSet", 0);\r
[Test]\r
public void ReadSimpleFragment ()\r
{\r
- DataSet ds = new DataSet ();\r
+ DataSet ds;\r
\r
// empty XML\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "EmptyString", xml1,\r
XmlReadMode.Fragment, XmlReadMode.Fragment,\r
"NewDataSet", 0);\r
\r
// simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "EmptyElement", xml2,\r
XmlReadMode.Fragment, XmlReadMode.Fragment,\r
"NewDataSet", 0);\r
\r
// simple element2\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "StartEndTag", xml3,\r
XmlReadMode.Fragment, XmlReadMode.Fragment,\r
"NewDataSet", 0);\r
\r
// whitespace in simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "Whitespace", xml4,\r
XmlReadMode.Fragment, XmlReadMode.Fragment,\r
"NewDataSet", 0);\r
\r
// text in simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SingleText", xml5,\r
XmlReadMode.Fragment, XmlReadMode.Fragment,\r
"NewDataSet", 0);\r
\r
// simple table pattern:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleTable", xml6,\r
XmlReadMode.Fragment, XmlReadMode.Fragment,\r
"NewDataSet", 0);\r
\r
// simple table with 2 columns:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleTable2", xml7,\r
XmlReadMode.Fragment, XmlReadMode.Fragment,\r
"NewDataSet", 0);\r
\r
// simple dataset with 1 table:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleDataSet", xml8,\r
XmlReadMode.Fragment, XmlReadMode.Fragment,\r
"NewDataSet", 0);\r
[Test]\r
public void ReadSimpleIgnoreSchema ()\r
{\r
- DataSet ds = new DataSet ();\r
+ DataSet ds;\r
\r
// empty XML\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "EmptyString", xml1,\r
XmlReadMode.IgnoreSchema, XmlReadMode.IgnoreSchema,\r
"NewDataSet", 0);\r
\r
// simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "EmptyElement", xml2,\r
XmlReadMode.IgnoreSchema, XmlReadMode.IgnoreSchema,\r
"NewDataSet", 0);\r
\r
// simple element2\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "StartEndTag", xml3,\r
XmlReadMode.IgnoreSchema, XmlReadMode.IgnoreSchema,\r
"NewDataSet", 0);\r
\r
// whitespace in simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "Whitespace", xml4,\r
XmlReadMode.IgnoreSchema, XmlReadMode.IgnoreSchema,\r
"NewDataSet", 0);\r
\r
// text in simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SingleText", xml5,\r
XmlReadMode.IgnoreSchema, XmlReadMode.IgnoreSchema,\r
"NewDataSet", 0);\r
\r
// simple table pattern:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleTable", xml6,\r
XmlReadMode.IgnoreSchema, XmlReadMode.IgnoreSchema,\r
"NewDataSet", 0);\r
\r
// simple table with 2 columns:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleTable2", xml7,\r
XmlReadMode.IgnoreSchema, XmlReadMode.IgnoreSchema,\r
"NewDataSet", 0);\r
\r
// simple dataset with 1 table:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleDataSet", xml8,\r
XmlReadMode.IgnoreSchema, XmlReadMode.IgnoreSchema,\r
"NewDataSet", 0);\r
[Test]\r
public void ReadSimpleInferSchema ()\r
{\r
- DataSet ds = new DataSet ();\r
+ DataSet ds;\r
\r
// empty XML\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "EmptyString", xml1,\r
XmlReadMode.InferSchema, XmlReadMode.InferSchema,\r
"NewDataSet", 0);\r
\r
// simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "EmptyElement", xml2,\r
XmlReadMode.InferSchema, XmlReadMode.InferSchema,\r
- "NewDataSet", 0);\r
+ "root", 0);\r
\r
// simple element2\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "StartEndTag", xml3,\r
XmlReadMode.InferSchema, XmlReadMode.InferSchema,\r
- "NewDataSet", 0);\r
+ "root", 0);\r
\r
// whitespace in simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "Whitespace", xml4,\r
XmlReadMode.InferSchema, XmlReadMode.InferSchema,\r
- "NewDataSet", 0);\r
+ "root", 0);\r
\r
// text in simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SingleText", xml5,\r
XmlReadMode.InferSchema, XmlReadMode.InferSchema,\r
- "NewDataSet", 0);\r
+ "root", 0);\r
\r
// simple table pattern:\r
// root becomes a table and test becomes a column.\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleTable", xml6,\r
XmlReadMode.InferSchema, XmlReadMode.InferSchema,\r
"NewDataSet", 1);\r
- AssertDataTable (ds.Tables [0], "root", 1, 1);\r
+ AssertDataTable ("xml6", ds.Tables [0], "root", 1, 1, 0, 0, 0, 0);\r
\r
// simple table with 2 columns:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleTable2", xml7,\r
XmlReadMode.InferSchema, XmlReadMode.InferSchema,\r
"NewDataSet", 1);\r
- AssertDataTable (ds.Tables [0], "root", 2, 1);\r
+ AssertDataTable ("xml7", ds.Tables [0], "root", 2, 1, 0, 0, 0, 0);\r
\r
// simple dataset with 1 table:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleDataSet", xml8,\r
XmlReadMode.InferSchema, XmlReadMode.InferSchema,\r
"dataset", 1);\r
- AssertDataTable (ds.Tables [0], "table", 2, 1);\r
+ AssertDataTable ("xml8", ds.Tables [0], "table", 2, 1, 0, 0, 0, 0);\r
}\r
\r
[Test]\r
public void ReadSimpleReadSchema ()\r
{\r
- DataSet ds = new DataSet ();\r
+ DataSet ds;\r
\r
// empty XML\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "EmptyString", xml1,\r
XmlReadMode.ReadSchema, XmlReadMode.ReadSchema,\r
"NewDataSet", 0);\r
\r
// simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "EmptyElement", xml2,\r
XmlReadMode.ReadSchema, XmlReadMode.ReadSchema,\r
"NewDataSet", 0);\r
\r
// simple element2\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "StartEndTag", xml3,\r
XmlReadMode.ReadSchema, XmlReadMode.ReadSchema,\r
"NewDataSet", 0);\r
\r
// whitespace in simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "Whitespace", xml4,\r
XmlReadMode.ReadSchema, XmlReadMode.ReadSchema,\r
"NewDataSet", 0);\r
\r
// text in simple element\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SingleText", xml5,\r
XmlReadMode.ReadSchema, XmlReadMode.ReadSchema,\r
"NewDataSet", 0);\r
\r
// simple table pattern:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleTable", xml6,\r
XmlReadMode.ReadSchema, XmlReadMode.ReadSchema,\r
"NewDataSet", 0);\r
\r
// simple table with 2 columns:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleTable2", xml7,\r
XmlReadMode.ReadSchema, XmlReadMode.ReadSchema,\r
"NewDataSet", 0);\r
\r
// simple dataset with 1 table:\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "SimpleDataSet", xml8,\r
XmlReadMode.ReadSchema, XmlReadMode.ReadSchema,\r
"NewDataSet", 0);\r
[Test]\r
public void TestSimpleDiffXmlAll ()\r
{\r
- DataSet ds = new DataSet ();\r
+ DataSet ds;\r
\r
// ignored\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "Fragment", diff1,\r
XmlReadMode.Fragment, XmlReadMode.Fragment,\r
"NewDataSet", 0);\r
\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "IgnoreSchema", diff1,\r
XmlReadMode.IgnoreSchema, XmlReadMode.IgnoreSchema,\r
"NewDataSet", 0);\r
\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "InferSchema", diff1,\r
XmlReadMode.InferSchema, XmlReadMode.InferSchema,\r
"NewDataSet", 0);\r
\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "ReadSchema", diff1,\r
XmlReadMode.ReadSchema, XmlReadMode.ReadSchema,\r
"NewDataSet", 0);\r
\r
// Auto, DiffGram ... treated as DiffGram\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "Auto", diff1,\r
XmlReadMode.Auto, XmlReadMode.DiffGram,\r
"NewDataSet", 0);\r
+\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "DiffGram", diff1,\r
XmlReadMode.DiffGram, XmlReadMode.DiffGram,\r
"NewDataSet", 0);\r
[Test]\r
public void TestSimpleDiffPlusContentAll ()\r
{\r
- DataSet ds = new DataSet ();\r
+ DataSet ds;\r
\r
// Fragment ... skipped\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "Fragment", diff2,\r
XmlReadMode.Fragment, XmlReadMode.Fragment,\r
"NewDataSet", 0);\r
\r
// others ... kept \r
+ ds = new DataSet ();\r
AssertReadXml (ds, "IgnoreSchema", diff2,\r
XmlReadMode.IgnoreSchema, XmlReadMode.IgnoreSchema,\r
"NewDataSet", 0, ReadState.Interactive);\r
\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "InferSchema", diff2,\r
XmlReadMode.InferSchema, XmlReadMode.InferSchema,\r
"NewDataSet", 0, ReadState.Interactive);\r
\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "ReadSchema", diff2,\r
XmlReadMode.ReadSchema, XmlReadMode.ReadSchema,\r
"NewDataSet", 0, ReadState.Interactive);\r
\r
// Auto, DiffGram ... treated as DiffGram\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "Auto", diff2,\r
XmlReadMode.Auto, XmlReadMode.DiffGram,\r
"NewDataSet", 0, ReadState.Interactive);\r
+\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "DiffGram", diff2,\r
XmlReadMode.DiffGram, XmlReadMode.DiffGram,\r
"NewDataSet", 0, ReadState.Interactive);\r
[Test]\r
public void TestSimpleSchemaXmlAll ()\r
{\r
- DataSet ds = new DataSet ();\r
+ DataSet ds;\r
\r
// ignored\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "IgnoreSchema", schema1,\r
XmlReadMode.IgnoreSchema, XmlReadMode.IgnoreSchema,\r
"NewDataSet", 0);\r
\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "InferSchema", schema1,\r
XmlReadMode.InferSchema, XmlReadMode.InferSchema,\r
"NewDataSet", 0);\r
\r
// misc ... consume schema\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "Fragment", schema1,\r
XmlReadMode.Fragment, XmlReadMode.Fragment,\r
"NewDataSet", 1);\r
- AssertDataTable (ds.Tables [0], "Root", 1, 0);\r
+ AssertDataTable ("fragment", ds.Tables [0], "Root", 1, 0, 0, 0, 0, 0);\r
\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "ReadSchema", schema1,\r
XmlReadMode.ReadSchema, XmlReadMode.ReadSchema,\r
"NewDataSet", 1);\r
- AssertDataTable (ds.Tables [0], "Root", 1, 0);\r
+ AssertDataTable ("readschema", ds.Tables [0], "Root", 1, 0, 0, 0, 0, 0);\r
\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "Auto", schema1,\r
XmlReadMode.Auto, XmlReadMode.ReadSchema,\r
"NewDataSet", 1);\r
- AssertDataTable (ds.Tables [0], "Root", 1, 0);\r
+ AssertDataTable ("auto", ds.Tables [0], "Root", 1, 0, 0, 0, 0, 0);\r
\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "DiffGram", schema1,\r
XmlReadMode.DiffGram, XmlReadMode.DiffGram,\r
"NewDataSet", 1);\r
[Test]\r
public void TestSimpleSchemaPlusContentAll ()\r
{\r
- DataSet ds = new DataSet ();\r
+ DataSet ds;\r
\r
// ignored\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "IgnoreSchema", schema2,\r
XmlReadMode.IgnoreSchema, XmlReadMode.IgnoreSchema,\r
"NewDataSet", 0, ReadState.Interactive);\r
\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "InferSchema", schema2,\r
XmlReadMode.InferSchema, XmlReadMode.InferSchema,\r
"NewDataSet", 0, ReadState.Interactive);\r
\r
// Fragment ... consumed both\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "Fragment", schema2,\r
XmlReadMode.Fragment, XmlReadMode.Fragment,\r
"NewDataSet", 1);\r
- AssertDataTable (ds.Tables [0], "Root", 1, 0);\r
+ AssertDataTable ("fragment", ds.Tables [0], "Root", 1, 0, 0, 0, 0, 0);\r
\r
// rest ... treated as schema\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "Auto", schema2,\r
XmlReadMode.Auto, XmlReadMode.ReadSchema,\r
"NewDataSet", 1, ReadState.Interactive);\r
- AssertDataTable (ds.Tables [0], "Root", 1, 0);\r
+ AssertDataTable ("auto", ds.Tables [0], "Root", 1, 0, 0, 0, 0, 0);\r
\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "DiffGram", schema2,\r
XmlReadMode.DiffGram, XmlReadMode.DiffGram,\r
"NewDataSet", 1, ReadState.Interactive);\r
- AssertDataTable (ds.Tables [0], "Root", 1, 0);\r
+ AssertDataTable ("diffgram", ds.Tables [0], "Root", 1, 0, 0, 0, 0, 0);\r
\r
+ ds = new DataSet ();\r
AssertReadXml (ds, "ReadSchema", schema2,\r
XmlReadMode.ReadSchema, XmlReadMode.ReadSchema,\r
"NewDataSet", 1, ReadState.Interactive);\r
}\r
\r
- /* To be added\r
[Test]\r
- public void SaveDiffLoadAutoSaveSchema ()\r
+ public void SequentialRead1 ()\r
{\r
+ // simple element -> simple table\r
+ DataSet ds = new DataSet ();\r
+\r
+ AssertReadXml (ds, "SingleText", xml5,\r
+ XmlReadMode.Auto, XmlReadMode.InferSchema,\r
+ "root", 0);\r
+\r
+ AssertReadXml (ds, "SimpleTable", xml6,\r
+ XmlReadMode.Auto, XmlReadMode.InferSchema,\r
+ "root", 1); // not NewDataSet unlike standalone load\r
+ AssertDataTable ("seq1", ds.Tables [0], "root", 1, 1, 0, 0, 0, 0);\r
+ }\r
+\r
+ [Test]\r
+ public void SequentialRead2 ()\r
+ {\r
+ // simple element -> simple dataset\r
+ DataSet ds = new DataSet ();\r
+\r
+ AssertReadXml (ds, "SingleText", xml5,\r
+ XmlReadMode.Auto, XmlReadMode.InferSchema,\r
+ "root", 0);\r
+\r
+ AssertReadXml (ds, "SimpleTable2", xml7,\r
+ XmlReadMode.Auto, XmlReadMode.InferSchema,\r
+ "root", 1); // dataset name will not be overwritten\r
+ AssertDataTable ("#1", ds.Tables [0], "root", 2, 1, 0, 0, 0, 0);\r
+\r
+ // simple table -> simple dataset\r
+ ds = new DataSet ();\r
+\r
+ AssertReadXml (ds, "SimpleTable", xml6,\r
+ XmlReadMode.Auto, XmlReadMode.InferSchema,\r
+ "NewDataSet", 1);\r
+ AssertDataTable ("#2", ds.Tables [0], "root", 1, 1, 0, 0, 0, 0);\r
+\r
+ // Return value became IgnoreSchema, since there is\r
+ // already schema information in the dataset.\r
+ // Columns are kept 1 as old table holds.\r
+ // Rows are up to 2 because of accumulative read.\r
+ AssertReadXml (ds, "SimpleTable2-2", xml7,\r
+ XmlReadMode.Auto, XmlReadMode.IgnoreSchema,\r
+ "NewDataSet", 1);\r
+ AssertDataTable ("#3", ds.Tables [0], "root", 1, 2, 0, 0, 0, 0);\r
+\r
+ }\r
+\r
+ [Test] // based on bug case\r
+ public void ReadComplexElementDocument ()\r
+ {\r
+ DataSet ds = new DataSet ();\r
+ ds.ReadXml (new StringReader (xml29));\r
+ }\r
+\r
+ [Test]\r
+ public void IgnoreSchemaShouldFillData ()\r
+ {\r
+ // no such dataset\r
+ string xml1 = "<set><tab><col>test</col></tab></set>";\r
+ // no wrapper element\r
+ string xml2 = "<tab><col>test</col></tab>";\r
+ // no such table\r
+ string xml3 = "<tar><col>test</col></tar>";\r
+ DataSet ds = new DataSet ();\r
+ DataTable dt = new DataTable ("tab");\r
+ ds.Tables.Add (dt);\r
+ dt.Columns.Add ("col");\r
+ ds.ReadXml (new StringReader (xml1), XmlReadMode.IgnoreSchema);\r
+ AssertDataSet ("ds", ds, "NewDataSet", 1, 0);\r
+ AssertEquals ("wrapper element", 1, dt.Rows.Count);\r
+ dt.Clear ();\r
+\r
+ ds.ReadXml (new StringReader (xml2), XmlReadMode.IgnoreSchema);\r
+ AssertEquals ("no wrapper element", 1, dt.Rows.Count);\r
+ dt.Clear ();\r
+\r
+ ds.ReadXml (new StringReader (xml3), XmlReadMode.IgnoreSchema);\r
+ AssertEquals ("no such table", 0, dt.Rows.Count);\r
+ }\r
+\r
+ // bug #60118\r
+ [Test]\r
+ public void NameConflictDSAndTable ()\r
+ {\r
+ string xml = @"<PriceListDetails> \r
+ <PriceListList> \r
+ <Id>1</Id>\r
+ </PriceListList>\r
+ <PriceListDetails> \r
+ <Id>1</Id>\r
+ <Status>0</Status>\r
+ </PriceListDetails>\r
+</PriceListDetails>";\r
+\r
DataSet ds = new DataSet ();\r
- ds.Tables.Add ("Table1");\r
- ds.Tables.Add ("Table2");\r
- ds.Tables [0].Columns.Add ("Column1_1");\r
- ds.Tables [0].Columns.Add ("Column1_2");\r
- ds.Tables [0].Columns.Add ("Column1_3");\r
- ds.Tables [1].Columns.Add ("Column2_1");\r
- ds.Tables [1].Columns.Add ("Column2_2");\r
- ds.Tables [1].Columns.Add ("Column2_3");\r
- ds.Tables [0].Rows.Add (new object [] {"ppp", "www", "xxx"});\r
-\r
- // save as diffgram\r
- StringWriter sw = new StringWriter ();\r
- ds.WriteXml (sw, XmlWriteMode.DiffGram);\r
- string xml = sw.ToString ();\r
- string result = new StreamReader ("Test/System.Data/DataSetReadXmlTest1.xml", Encoding.ASCII).ReadToEnd ();\r
- AssertEquals ("#01", result, xml);\r
-\r
- // load diffgram above\r
- ds.ReadXml (new StringReader (sw.ToString ()));\r
- sw = new StringWriter ();\r
- ds.WriteXml (sw, XmlWriteMode.WriteSchema);\r
- xml = sw.ToString ();\r
- result = new StreamReader ("Test/System.Data/DataSetReadXmlTest2.xml", Encoding.ASCII).ReadToEnd ();\r
- AssertEquals ("#02", result, xml);\r
+ ds.ReadXml (new StringReader (xml));\r
+ AssertNotNull (ds.Tables ["PriceListDetails"]);\r
}\r
- */\r
}\r
}\r