AssertDataColumn() публичный Метод

public AssertDataColumn ( string label, DataColumn col, string colName, bool allowDBNull, bool autoIncr, int autoIncrSeed, int autoIncrStep, string caption, MappingType colMap, Type type, object defaultValue, string expression, int maxLength, string ns, int ordinal, string prefix, bool readOnly, bool unique ) : void
label string
col DataColumn
colName string
allowDBNull bool
autoIncr bool
autoIncrSeed int
autoIncrStep int
caption string
colMap MappingType
type Type
defaultValue object
expression string
maxLength int
ns string
ordinal int
prefix string
readOnly bool
unique bool
Результат void
Пример #1
0
        public void TestSampleFileComplexTables3()
        {
            var ds = new DataSet();

            ds.Tables.Add(new DataTable("e"));
            ds.Tables[0].ReadXmlSchema(new StringReader(
                                           @"<!-- Modified w3ctests attQ014.xsd -->
                <xsd:schema xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" targetNamespace=""http://xsdtesting"" xmlns:x=""http://xsdtesting"">
                    <xsd:element name=""root"">
                        <xsd:complexType>
                            <xsd:sequence>
                                <xsd:element name=""e"">
                                    <xsd:complexType>
                                        <xsd:simpleContent>
                                            <xsd:extension base=""xsd:decimal"">
                                                <xsd:attribute name=""a"" type=""xsd:string""/>
                                            </xsd:extension>
                                        </xsd:simpleContent>
                                    </xsd:complexType>
                                </xsd:element>
                            </xsd:sequence>
                        </xsd:complexType>
                    </xsd:element>
                </xsd:schema>"));
            DataTable dt = ds.Tables[0];

            DataSetAssertion.AssertDataTable("root", dt, "e", 2, 0, 0, 0, 0, 0);
            DataSetAssertion.AssertDataColumn("attr", dt.Columns[0], "a", true, false, 0, 1, "a", MappingType.Attribute, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("simple", dt.Columns[1], "e_text", false, false, 0, 1, "e_text", MappingType.SimpleContent, typeof(decimal), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);
        }
Пример #2
0
        public void LocaleOnRootWithoutIsDataSet()
        {
            using (new ThreadCultureChange("fi-FI"))
            {
                string xs = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'>
<xs:element name='Root' msdata:Locale='ja-JP'>
    <xs:complexType>
        <xs:sequence>
            <xs:element name='Child' type='xs:string' />
        </xs:sequence>
        <xs:attribute name='Attr' type='xs:integer' />
    </xs:complexType>
</xs:element>
</xs:schema>";

                var ds = new DataSet();
                ds.ReadXmlSchema(new StringReader(xs));
                DataSetAssertion.AssertDataSet("ds", ds, "NewDataSet", 1, 0);
                Assert.Equal("fi-FI", ds.Locale.Name); // DataSet's Locale comes from current thread
                DataTable dt = ds.Tables[0];
                DataSetAssertion.AssertDataTable("dt", dt, "Root", 2, 0, 0, 0, 0, 0);
                Assert.Equal("ja-JP", dt.Locale.Name); // DataTable's Locale comes from msdata:Locale
                DataSetAssertion.AssertDataColumn("col1", dt.Columns[0], "Attr", true, false, 0, 1, "Attr", MappingType.Attribute, typeof(long), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
                DataSetAssertion.AssertDataColumn("col2", dt.Columns[1], "Child", false, false, 0, 1, "Child", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);
            }
        }
Пример #3
0
        public void RepeatableSimpleElement()
        {
            var ds = new DataSet();

            ds.ReadXmlSchema(new StringReader(
                                 @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
                  <!-- empty -->
                  <xs:element name='Foo' type='FooType' />
                  <!-- defining externally to avoid being regarded as dataset element -->
                  <xs:complexType name='FooType'>
                    <xs:sequence>
                        <xs:element name='Bar' maxOccurs='2' />
                    </xs:sequence>
                  </xs:complexType>
                </xs:schema>"));
            DataSetAssertion.AssertDataSet("012", ds, "NewDataSet", 2, 1);
            DataTable dt = ds.Tables[0];

            DataSetAssertion.AssertDataTable("parent", dt, "Foo", 1, 0, 0, 1, 1, 1);
            DataSetAssertion.AssertDataColumn("key", dt.Columns[0], "Foo_Id", false, true, 0, 1, "Foo_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, true);

            dt = ds.Tables[1];
            DataSetAssertion.AssertDataTable("repeated", dt, "Bar", 2, 0, 1, 0, 1, 0);
            DataSetAssertion.AssertDataColumn("data", dt.Columns[0], "Bar_Column", false, false, 0, 1, "Bar_Column", MappingType.SimpleContent, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("refkey", dt.Columns[1], "Foo_Id", true, false, 0, 1, "Foo_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);

            DataSetAssertion.AssertDataRelation("rel", ds.Relations[0], "Foo_Bar", true, new string[] { "Foo_Id" }, new string[] { "Foo_Id" }, true, true);
        }
Пример #4
0
        public void PrefixedTargetNS()
        {
            string xs = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata' xmlns:x='urn:foo' targetNamespace='urn:foo' elementFormDefault='qualified'>
    <xs:element name='DS' msdata:IsDataSet='true'>
        <xs:complexType>
            <xs:choice>
                <xs:element ref='x:R1' />
                <xs:element ref='x:R2' />
            </xs:choice>
        </xs:complexType>
        <xs:key name='key'>
            <xs:selector xpath='./any/string_is_OK/x:R1'/>
            <xs:field xpath='x:Child2'/>
        </xs:key>
        <xs:keyref name='kref' refer='x:key'>
            <xs:selector xpath='.//x:R2'/>
            <xs:field xpath='x:Child2'/>
        </xs:keyref>
    </xs:element>
    <xs:element name='R3' type='x:RootType' />
    <xs:complexType name='extracted'>
        <xs:choice>
            <xs:element ref='x:R1' />
            <xs:element ref='x:R2' />
        </xs:choice>
    </xs:complexType>
    <xs:element name='R1' type='x:RootType'>
        <xs:unique name='Rkey'>
            <xs:selector xpath='.//x:Child1'/>
            <xs:field xpath='.'/>
        </xs:unique>
        <xs:keyref name='Rkref' refer='x:Rkey'>
            <xs:selector xpath='.//x:Child2'/>
            <xs:field xpath='.'/>
        </xs:keyref>
    </xs:element>
    <xs:element name='R2' type='x:RootType'>
    </xs:element>
    <xs:complexType name='RootType'>
        <xs:choice>
            <xs:element name='Child1' type='xs:string'>
            </xs:element>
            <xs:element name='Child2' type='xs:string' />
        </xs:choice>
        <xs:attribute name='Attr' type='xs:integer' />
    </xs:complexType>
</xs:schema>";
            // No prefixes on tables and columns
            var ds = new DataSet();

            ds.Tables.Add(new DataTable("R3"));
            ds.Tables[0].ReadXmlSchema(new StringReader(xs));
            DataTable dt = ds.Tables[0];

            DataSetAssertion.AssertDataTable("R3", dt, "R3", 3, 0, 0, 0, 0, 0);
            DataSetAssertion.AssertDataColumn("col1", dt.Columns[0], "Attr", true, false, 0, 1, "Attr", MappingType.Attribute, typeof(long), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
        }
Пример #5
0
        public void SingleElementWithAttribute()
        {
            DataSet ds = GetDataSet(_xml2, null);

            DataSetAssertion.AssertDataSet("ds", ds, "NewDataSet", 1, 0);
            DataTable dt = ds.Tables[0];

            DataSetAssertion.AssertDataTable("dt", dt, "root", 1, 0, 0, 0, 0, 0);
            DataSetAssertion.AssertDataColumn("col", dt.Columns[0], "attr", true, false, 0, 1, "attr", MappingType.Attribute, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
        }
Пример #6
0
        public void SimpleDataSet()
        {
            DataSet ds = GetDataSet(_xml8, null);

            DataSetAssertion.AssertDataSet("ds", ds, "set", 1, 0);
            DataTable dt = ds.Tables[0];

            DataSetAssertion.AssertDataTable("dt", dt, "tab", 3, 0, 0, 0, 0, 0);
            DataSetAssertion.AssertDataColumn("col", dt.Columns[0], "col1", true, false, 0, 1, "col1", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("col2", dt.Columns[1], "col2", true, false, 0, 1, "col2", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("col3", dt.Columns[2], "col3", true, false, 0, 1, "col3", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 2, string.Empty, false, false);
        }
Пример #7
0
        public void MixedContent()
        {
            // Note that text part is ignored.

            DataSet ds = GetDataSet(_xml10, null);

            DataSetAssertion.AssertDataSet("ds", ds, "NewDataSet", 1, 0);
            DataTable dt = ds.Tables[0];

            DataSetAssertion.AssertDataTable("dt", dt, "root", 1, 0, 0, 0, 0, 0);
            DataSetAssertion.AssertDataColumn("col", dt.Columns[0], "b", true, false, 0, 1, "b", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
        }
Пример #8
0
        public void SignificantWhitespaceIgnored()
        {
            // Note that 1) significant whitespace is ignored, and
            // 2) xml:space is treated as column (and also note namespaces).
            DataSet ds = GetDataSet(_xml11, null);

            DataSetAssertion.AssertDataSet("ds", ds, "NewDataSet", 1, 0);
            DataTable dt = ds.Tables[0];

            DataSetAssertion.AssertDataTable("dt", dt, "root", 1, 0, 0, 0, 0, 0);
            DataSetAssertion.AssertDataColumn("element", dt.Columns[0], "child_after_significant_space", true, false, 0, 1, "child_after_significant_space", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
            Assert.Equal(1, dt.Columns.Count);
        }
Пример #9
0
        public void TestAnnotatedRelation2()
        {
            var ds = new DataSet();

            ds.ReadXmlSchema(new StringReader(
                                 @"<xs:schema xmlns:xs=""http://www.w3.org/2001/XMLSchema"" xmlns:msdata=""urn:schemas-microsoft-com:xml-msdata"">
                <!-- just modified MSDN example -->
                <xs:element name=""ds"" msdata:IsDataSet=""true"">
                 <xs:complexType>
                  <xs:choice maxOccurs=""unbounded"">
                   <xs:element name=""p"">
                    <xs:complexType>
                     <xs:sequence>
                       <xs:element name=""pk"" type=""xs:string"" />
                       <xs:element name=""name"" type=""xs:string"" />
                       <xs:element name=""c"">
                          <xs:annotation>
                           <xs:appinfo>
                            <msdata:Relationship name=""rel""
                             msdata:parent=""p""
                             msdata:child=""c""
                             msdata:parentkey=""pk""
                             msdata:childkey=""fk""/>
                           </xs:appinfo>
                          </xs:annotation>
                          <xs:complexType>
                            <xs:sequence>
                             <xs:element name=""fk"" type=""xs:string"" />
                             <xs:element name=""count"" type=""xs:int"" />
                            </xs:sequence>
                         </xs:complexType>
                       </xs:element>
                     </xs:sequence>
                    </xs:complexType>
                   </xs:element>
                  </xs:choice>
                 </xs:complexType>
                </xs:element>
                </xs:schema>"));
            DataSetAssertion.AssertDataSet("102", ds, "ds", 2, 1);
            DataTable dt = ds.Tables[0];

            DataSetAssertion.AssertDataTable("parent_table", dt, "p", 2, 0, 0, 1, 0, 0);
            DataSetAssertion.AssertDataColumn("pk", dt.Columns[0], "pk", false, false, 0, 1, "pk", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);

            dt = ds.Tables[1];
            DataSetAssertion.AssertDataTable("child_table", dt, "c", 2, 0, 1, 0, 0, 0);
            DataSetAssertion.AssertDataColumn("fk", dt.Columns[0], "fk", false, false, 0, 1, "fk", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);

            DataSetAssertion.AssertDataRelation("rel", ds.Relations[0], "rel", true, new string[] { "pk" }, new string[] { "fk" }, false, false);
        }
Пример #10
0
        public void SingleChild()
        {
            DataSet ds = GetDataSet(_xml5, null);

            DataSetAssertion.AssertDataSet("ds", ds, "NewDataSet", 1, 0);
            DataTable dt = ds.Tables[0];

            DataSetAssertion.AssertDataTable("dt", dt, "root", 1, 0, 0, 0, 0, 0);
            DataSetAssertion.AssertDataColumn("col", dt.Columns[0], "child", true, false, 0, 1, "child", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);

            ds = GetDataSet(_xml6, null);
            DataSetAssertion.AssertDataSet("ds", ds, "NewDataSet", 1, 0);
            dt = ds.Tables[0];
            DataSetAssertion.AssertDataTable("dt", dt, "root", 1, 0, 0, 0, 0, 0);
            DataSetAssertion.AssertDataColumn("col", dt.Columns[0], "col1", true, false, 0, 1, "col1", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
        }
Пример #11
0
        public void TwoElementTable()
        {
            // FIXME: Also test ReadXml (, XmlReadMode.InferSchema) and
            // make sure that ReadXml() stores DataRow to el1 (and maybe to others)
            DataSet ds = GetDataSet(_xml15, null);

            DataSetAssertion.AssertDataSet("ds", ds, "root", 2, 0);

            DataTable dt = ds.Tables[0];

            DataSetAssertion.AssertDataTable("dt", dt, "table1", 2, 0, 0, 0, 0, 0);
            DataSetAssertion.AssertDataColumn("col1_1", dt.Columns[0], "col1_1", true, false, 0, 1, "col1_1", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("col1_2", dt.Columns[1], "col1_2", true, false, 0, 1, "col1_2", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);

            dt = ds.Tables[1];
            DataSetAssertion.AssertDataTable("dt", dt, "table2", 2, 0, 0, 0, 0, 0);
            DataSetAssertion.AssertDataColumn("col2_1", dt.Columns[0], "col2_1", true, false, 0, 1, "col2_1", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("col2_2", dt.Columns[1], "col2_2", true, false, 0, 1, "col2_2", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);
        }
Пример #12
0
        public void TestSampleFileSimpleTables()
        {
            var ds = new DataSet();

            ds.Tables.Add(new DataTable("foo"));
            ds.Tables[0].ReadXmlSchema(new StringReader(
                                           @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
                <xs:element name='foo' type='ct' />
                <xs:complexType name='ct'>
                  <xs:simpleContent>
                    <xs:extension base='xs:integer'>
                      <xs:attribute name='attr' />
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
                </xs:schema>"));
            DataSetAssertion.AssertDataSet("005", ds, "NewDataSet", 1, 0);
            DataTable dt = ds.Tables[0];

            DataSetAssertion.AssertDataTable("tab", dt, "foo", 2, 0, 0, 0, 0, 0);
            DataSetAssertion.AssertDataColumn("attr", dt.Columns[0], "attr", true, false, 0, 1, "attr", MappingType.Attribute, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("text", dt.Columns[1], "foo_text", false, false, 0, 1, "foo_text", MappingType.SimpleContent, typeof(long), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);

            ds = new DataSet();
            ds.Tables.Add(new DataTable("foo"));
            ds.Tables[0].ReadXmlSchema(new StringReader(
                                           @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
                    <xs:element name='foo' type='st' />
                    <xs:complexType name='st'>
                      <xs:attribute name='att1' />
                      <xs:attribute name='att2' type='xs:int' default='2' />
                    </xs:complexType>
                </xs:schema>"));
            DataSetAssertion.AssertDataSet("006", ds, "NewDataSet", 1, 0);
            dt = ds.Tables[0];
            DataSetAssertion.AssertDataTable("tab", dt, "foo", 2, 0, 0, 0, 0, 0);
            DataSetAssertion.AssertDataColumn("att1", dt.Columns["att1"], "att1", true, false, 0, 1, "att1", MappingType.Attribute, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, /*0*/ -1, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("att2", dt.Columns["att2"], "att2", true, false, 0, 1, "att2", MappingType.Attribute, typeof(int), 2, string.Empty, -1, string.Empty, /*1*/ -1, string.Empty, false, false);
        }
Пример #13
0
        public void ConflictColumnTable()
        {
            DataSet ds = GetDataSet(_xml19, null);

            DataSetAssertion.AssertDataSet("ds", ds, "set", 2, 1);

            DataTable dt = ds.Tables[0];

            DataSetAssertion.AssertDataTable("dt", dt, "table", 1, 0, 0, 1, 1, 1);
            DataSetAssertion.AssertDataColumn("table_Id", dt.Columns[0], "table_Id", false, true, 0, 1, "table_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, true);

            dt = ds.Tables[1];
            DataSetAssertion.AssertDataTable("dt", dt, "col", 2, 0, 1, 0, 1, 0);
            DataSetAssertion.AssertDataColumn("table_refId", dt.Columns["table_Id"], "table_Id", true, false, 0, 1, "table_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, /*0*/ -1, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("another_col", dt.Columns["another_col"], "another_col", true, false, 0, 1, "another_col", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, /*1*/ -1, string.Empty, false, false);

            DataRelation dr = ds.Relations[0];

            DataSetAssertion.AssertDataRelation("rel", dr, "table_col", true, new string[] { "table_Id" }, new string[] { "table_Id" }, true, true);
            DataSetAssertion.AssertUniqueConstraint("uniq", dr.ParentKeyConstraint, "Constraint1", true, new string[] { "table_Id" });
            DataSetAssertion.AssertForeignKeyConstraint("fkey", dr.ChildKeyConstraint, "table_col", AcceptRejectRule.None, Rule.Cascade, Rule.Cascade, new string[] { "table_Id" }, new string[] { "table_Id" });
        }
Пример #14
0
        public void ComplexElementAttributeTable1()
        {
            // FIXME: Also test ReadXml (, XmlReadMode.InferSchema) and
            // make sure that ReadXml() stores DataRow to el1 (and maybe to others)
            DataSet ds = GetDataSet(_xml9, null);

            DataSetAssertion.AssertDataSet("ds", ds, "NewDataSet", 4, 3);
            DataTable dt = ds.Tables[0];

            DataSetAssertion.AssertDataTable("dt1", dt, "el1", 3, 0, 0, 1, 1, 1);
            DataSetAssertion.AssertDataColumn("el1_Id", dt.Columns[0], "el1_Id", false, true, 0, 1, "el1_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, true);
            DataSetAssertion.AssertDataColumn("el1_attr1", dt.Columns[1], "attr1", true, false, 0, 1, "attr1", MappingType.Attribute, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("el1_attrA", dt.Columns[2], "attrA", true, false, 0, 1, "attrA", MappingType.Attribute, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 2, string.Empty, false, false);

            dt = ds.Tables[1];
            DataSetAssertion.AssertDataTable("dt2", dt, "el2", 6, 0, 1, 2, 2, 1);
            DataSetAssertion.AssertDataColumn("el2_Id", dt.Columns[0], "el2_Id", false, true, 0, 1, "el2_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, true);
            DataSetAssertion.AssertDataColumn("el2_col2", dt.Columns[1], "column2", true, false, 0, 1, "column2", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("el2_col3", dt.Columns[2], "column3", true, false, 0, 1, "column3", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 2, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("el2_attr2", dt.Columns[3], "attr2", true, false, 0, 1, "attr2", MappingType.Attribute, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 3, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("el2_attrB", dt.Columns[4], "attrB", true, false, 0, 1, "attrB", MappingType.Attribute, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 4, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("el2_el1Id", dt.Columns[5], "el1_Id", true, false, 0, 1, "el1_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 5, string.Empty, false, false);

            dt = ds.Tables[2];
            DataSetAssertion.AssertDataTable("dt3", dt, "el3", 4, 0, 1, 0, 1, 0);
            DataSetAssertion.AssertDataColumn("el3_attr3", dt.Columns[0], "attr3", true, false, 0, 1, "attr3", MappingType.Attribute, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("el3_attrC", dt.Columns[1], "attrC", true, false, 0, 1, "attrC", MappingType.Attribute, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("el3_Text", dt.Columns[2], "el3_Text", true, false, 0, 1, "el3_Text", MappingType.SimpleContent, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 2, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("el3_el2Id", dt.Columns[3], "el2_Id", true, false, 0, 1, "el2_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 3, string.Empty, false, false);

            dt = ds.Tables[3];
            DataSetAssertion.AssertDataTable("dt4", dt, "el4", 4, 0, 1, 0, 1, 0);
            DataSetAssertion.AssertDataColumn("el3_attr4", dt.Columns[0], "attr4", true, false, 0, 1, "attr4", MappingType.Attribute, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("el4_attrD", dt.Columns[1], "attrD", true, false, 0, 1, "attrD", MappingType.Attribute, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("el4_Text", dt.Columns[2], "el4_Text", true, false, 0, 1, "el4_Text", MappingType.SimpleContent, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 2, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("el4_el2Id", dt.Columns[3], "el2_Id", true, false, 0, 1, "el2_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 3, string.Empty, false, false);
        }
Пример #15
0
        public void TestMoreThanOneRepeatableColumns()
        {
            var ds = new DataSet();

            ds.ReadXmlSchema(new StringReader(
                                 @"<xsd:schema xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
                    <xsd:element name=""root"">
                        <xsd:complexType>
                            <xsd:sequence>
                                <xsd:element name=""x"" maxOccurs=""2"" />
                                <xsd:element ref=""y"" maxOccurs=""unbounded"" />
                            </xsd:sequence>
                        </xsd:complexType>
                    </xsd:element>
                    <xsd:element name=""y"" />
                </xsd:schema>"));
            DataSetAssertion.AssertDataSet("014", ds, "NewDataSet", 3, 2);

            DataTable dt = ds.Tables[0];

            DataSetAssertion.AssertDataTable("parent", dt, "root", 1, 0, 0, 2, 1, 1);
            DataSetAssertion.AssertDataColumn("key", dt.Columns[0], "root_Id", false, true, 0, 1, "root_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, true);

            dt = ds.Tables[1];
            DataSetAssertion.AssertDataTable("repeated", dt, "x", 2, 0, 1, 0, 1, 0);
            DataSetAssertion.AssertDataColumn("data_1", dt.Columns[0], "x_Column", false, false, 0, 1, "x_Column", MappingType.SimpleContent, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("refkey_1", dt.Columns[1], "root_Id", true, false, 0, 1, "root_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);

            dt = ds.Tables[2];
            DataSetAssertion.AssertDataTable("repeated", dt, "y", 2, 0, 1, 0, 1, 0);
            DataSetAssertion.AssertDataColumn("data", dt.Columns[0], "y_Column", false, false, 0, 1, "y_Column", MappingType.SimpleContent, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("refkey", dt.Columns[1], "root_Id", true, false, 0, 1, "root_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);

            DataSetAssertion.AssertDataRelation("rel", ds.Relations[0], "root_x", true, new string[] { "root_Id" }, new string[] { "root_Id" }, true, true);

            DataSetAssertion.AssertDataRelation("rel", ds.Relations[1], "root_y", true, new string[] { "root_Id" }, new string[] { "root_Id" }, true, true);
        }
Пример #16
0
        public void SingleElementTreatmentDifference()
        {
            // This is one of the most complicated case. When the content
            // type particle of 'Root' element is a complex element, it
            // is DataSet element. Otherwise, it is just a data table.
            //
            // But also note that there is another test named
            // LocaleOnRootWithoutIsDataSet(), that tests if locale on
            // the (mere) data table modifies *DataSet's* locale.

            // Moreover, when the schema contains another element
            // (regardless of its schema type), the elements will
            // never be treated as a DataSet.
            string xsbase = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' id='hoge'>
    <xs:element name='Root'> <!-- When simple, it becomes table. When complex, it becomes DataSet -->
        <xs:complexType>
            <xs:choice>
                {0}
            </xs:choice>
        </xs:complexType>
    </xs:element>
</xs:schema>";

            string xsbase2 = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' id='hoge'>
    <xs:element name='Root'> <!-- When simple, it becomes table. When complex, it becomes DataSet -->
        <xs:complexType>
            <xs:choice>
                {0}
            </xs:choice>
        </xs:complexType>
    </xs:element>
    <xs:element name='more' type='xs:string' />
</xs:schema>";

            string simple  = "<xs:element name='Child' type='xs:string' />";
            string complex = @"<xs:element name='Child'>
    <xs:complexType>
        <xs:attribute name='a1' />
        <xs:attribute name='a2' type='xs:integer' />
    </xs:complexType>
</xs:element>";
            string elref   = "<xs:element ref='more' />";

            string xs2 = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' id='hoge'>
    <xs:element name='Root' type='RootType' />
    <xs:complexType name='RootType'>
        <xs:choice>
            <xs:element name='Child'>
                <xs:complexType>
                    <xs:attribute name='a1' />
                    <xs:attribute name='a2' type='xs:integer' />
                </xs:complexType>
            </xs:element>
        </xs:choice>
    </xs:complexType>
</xs:schema>";

            var ds = new DataSet();

            string xs = string.Format(xsbase, simple);

            ds.ReadXmlSchema(new StringReader(xs));
            DataSetAssertion.AssertDataSet("simple", ds, "hoge", 1, 0);
            DataSetAssertion.AssertDataTable("simple", ds.Tables[0], "Root", 1, 0, 0, 0, 0, 0);

            // reference to global complex type
            ds = new DataSet();
            ds.ReadXmlSchema(new StringReader(xs2));
            DataSetAssertion.AssertDataSet("external complexType", ds, "hoge", 2, 1);
            DataSetAssertion.AssertDataTable("external Tab1", ds.Tables[0], "Root", 1, 0, 0, 1, 1, 1);
            DataSetAssertion.AssertDataTable("external Tab2", ds.Tables[1], "Child", 3, 0, 1, 0, 1, 0);

            // xsbase2 + complex -> datatable
            ds = new DataSet();
            xs = string.Format(xsbase2, complex);
            ds.ReadXmlSchema(new StringReader(xs));
            DataSetAssertion.AssertDataSet("complex", ds, "hoge", 2, 1);
            DataSetAssertion.AssertDataTable("complex", ds.Tables[0], "Root", 1, 0, 0, 1, 1, 1);
            DataTable dt = ds.Tables[1];

            DataSetAssertion.AssertDataTable("complex", dt, "Child", 3, 0, 1, 0, 1, 0);
            DataSetAssertion.AssertDataColumn("a1", dt.Columns["a1"], "a1", true, false, 0, 1, "a1", MappingType.Attribute, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, /*0*/ -1, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("a2", dt.Columns["a2"], "a2", true, false, 0, 1, "a2", MappingType.Attribute, typeof(long), DBNull.Value, string.Empty, -1, string.Empty, /*1*/ -1, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("Root_Id", dt.Columns[2], "Root_Id", true, false, 0, 1, "Root_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 2, string.Empty, false, false);

            // xsbase + complex -> dataset
            ds = new DataSet();
            xs = string.Format(xsbase, complex);
            ds.ReadXmlSchema(new StringReader(xs));
            DataSetAssertion.AssertDataSet("complex", ds, "Root", 1, 0);

            ds = new DataSet();
            xs = string.Format(xsbase2, elref);
            ds.ReadXmlSchema(new StringReader(xs));
            DataSetAssertion.AssertDataSet("complex", ds, "hoge", 1, 0);
            DataSetAssertion.AssertDataTable("complex", ds.Tables[0], "Root", 1, 0, 0, 0, 0, 0);
        }
Пример #17
0
        public void TestSampleFileComplexTables()
        {
            // Nested simple type element
            var ds = new DataSet();

            ds.ReadXmlSchema(new StringReader(
                                 @"<!-- nested tables, root references to complex type -->
                <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='urn:foo' xmlns:x='urn:foo'>
                  <xs:element name='uno' type='x:t' />
                  <xs:complexType name='t'>
                    <xs:sequence>
                      <xs:element name='des'>
                        <xs:complexType>
                          <xs:sequence>
                            <xs:element name='tres' />
                          </xs:sequence>
                        </xs:complexType>
                      </xs:element>
                    </xs:sequence>
                  </xs:complexType>
                </xs:schema>"));
            DataSetAssertion.AssertDataSet("007", ds, "NewDataSet", 2, 1);
            DataTable dt = ds.Tables[0];

            DataSetAssertion.AssertDataTable("tab1", dt, "uno", 1, 0, 0, 1, 1, 1);
            DataSetAssertion.AssertDataColumn("id", dt.Columns[0], "uno_Id", false, true, 0, 1, "uno_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, "urn:foo", 0, string.Empty, false, true);

            dt = ds.Tables[1];
            DataSetAssertion.AssertDataTable("tab2", dt, "des", 2, 0, 1, 0, 1, 0);
            DataSetAssertion.AssertDataColumn("child", dt.Columns[0], "tres", false, false, 0, 1, "tres", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 0, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("id", dt.Columns[1], "uno_Id", true, false, 0, 1, "uno_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);

            // External simple type element
            ds = new DataSet();
            ds.ReadXmlSchema(new StringReader(
                                 @"<!-- reference to external simple element -->
                <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='urn:foo' xmlns:x='urn:foo'>
                  <xs:element name='uno' type='x:t' />
                  <xs:element name='tres' type='xs:string' />
                  <xs:complexType name='t'>
                    <xs:sequence>
                      <xs:element name='des'>
                        <xs:complexType>
                          <xs:sequence>
                            <xs:element ref='x:tres' />
                          </xs:sequence>
                        </xs:complexType>
                      </xs:element>
                    </xs:sequence>
                  </xs:complexType>
                </xs:schema>"));
            DataSetAssertion.AssertDataSet("008", ds, "NewDataSet", 2, 1);
            dt = ds.Tables[0];
            DataSetAssertion.AssertDataTable("tab1", dt, "uno", 1, 0, 0, 1, 1, 1);
            DataSetAssertion.AssertDataColumn("id", dt.Columns[0], "uno_Id", false, true, 0, 1, "uno_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, "urn:foo", 0, string.Empty, false, true);

            dt = ds.Tables[1];
            DataSetAssertion.AssertDataTable("tab2", dt, "des", 2, 0, 1, 0, 1, 0);
            DataSetAssertion.AssertDataColumn("child", dt.Columns[0], "tres", false, false, 0, 1, "tres", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, "urn:foo", 0, string.Empty, false, false);
            DataSetAssertion.AssertDataColumn("id", dt.Columns[1], "uno_Id", true, false, 0, 1, "uno_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);
        }