System.Data.Tests.DataTableReadXmlSchemaTest.IsDataSetAndTypeIgnored C# (CSharp) Method

IsDataSetAndTypeIgnored() private method

private IsDataSetAndTypeIgnored ( ) : void
return void
        public void IsDataSetAndTypeIgnored()
        {
            string xsbase = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'>
	<xs:element name='Root' type='unusedType' msdata:IsDataSet='{0}'>
	</xs:element>
	<xs:complexType name='unusedType'>
		<xs:sequence>
			<xs:element name='Child' type='xs:string' />
		</xs:sequence>
	</xs:complexType>
</xs:schema>";

            Assert.Throws<ArgumentException>(() =>
            {
                // When explicit msdata:IsDataSet value is "false", then
                // treat as usual.
                string xs = string.Format(xsbase, "false");
                var ds = new DataSet();
                ds.Tables.Add(new DataTable("Root"));
                ds.Tables[0].ReadXmlSchema(new StringReader(xs));
                AssertDataTable("dt", ds.Tables[0], "Root", 1, 0, 0, 0, 0, 0);

                // Even if a global element uses a complexType, it will be
                // ignored if the element has msdata:IsDataSet='true'
                xs = string.Format(xsbase, "true");
                ds = new DataSet();
                ds.Tables.Add(new DataTable("Root"));
                ds.Tables[0].ReadXmlSchema(new StringReader(xs));
            });
        }