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

NestedReferenceNotAllowed() private method

private NestedReferenceNotAllowed ( ) : void
return void
        public void NestedReferenceNotAllowed()
        {
            string xs = @"<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='true'>
	</xs:element>
	<xs:complexType name='unusedType'>
		<xs:sequence>
			<xs:element name='Child' type='xs:string' />
		</xs:sequence>
	</xs:complexType>
	<xs:element name='Foo'>
		<xs:complexType>
			<xs:sequence>
				<xs:element ref='Root' />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>";

            Assert.Throws<ArgumentException>(() =>
            {
                // DataSet element cannot be converted into a DataTable.
                // (i.e. cannot be referenced in any other elements)
                var ds = new DataSet();
                ds.Tables.Add(new DataTable());
                ds.Tables[0].ReadXmlSchema(new StringReader(xs));
            });
        }