public AssertDataRelation ( string label, DataRelation rel, string name, bool nested, string parentColNames, string childColNames, bool existsUK, bool existsFK ) : void | ||
label | string | |
rel | DataRelation | |
name | string | |
nested | bool | |
parentColNames | string | |
childColNames | string | |
existsUK | bool | |
existsFK | bool | |
Результат | void |
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); }
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); }
public void ReadAnnotatedRelations_MultipleColumns() { var ds = new DataSet(); ds.ReadXmlSchema(new StringReader( @"<?xml version=""1.0"" standalone=""yes""?> <xs:schema id=""NewDataSet"" xmlns="""" xmlns:xs=""http://www.w3.org/2001/XMLSchema"" xmlns:msdata=""urn:schemas-microsoft-com:xml-msdata""> <xs:element name=""NewDataSet"" msdata:IsDataSet=""true""> <xs:complexType> <xs:choice maxOccurs=""unbounded""> <xs:element name=""Table1""> <xs:complexType> <xs:sequence> <xs:element name=""col_x0020_1"" type=""xs:int"" minOccurs=""0"" /> <xs:element name=""col2"" type=""xs:int"" minOccurs=""0"" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name=""Table2""> <xs:complexType> <xs:sequence> <xs:element name=""col1"" type=""xs:int"" minOccurs=""0"" /> <xs:element name=""col_x0020__x0020_2"" type=""xs:int"" minOccurs=""0"" /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element> <xs:annotation> <xs:appinfo> <msdata:Relationship name=""rel"" msdata:parent=""Table1"" msdata:child=""Table2"" msdata:parentkey=""col_x0020_1 col2"" msdata:childkey=""col1 col_x0020__x0020_2"" /> </xs:appinfo> </xs:annotation> </xs:schema>")); Assert.Equal(1, ds.Relations.Count); Assert.Equal("rel", ds.Relations[0].RelationName); Assert.Equal(2, ds.Relations[0].ParentColumns.Length); Assert.Equal(2, ds.Relations[0].ChildColumns.Length); Assert.Equal(0, ds.Tables[0].Constraints.Count); Assert.Equal(0, ds.Tables[1].Constraints.Count); DataSetAssertion.AssertDataRelation("TestRel", ds.Relations[0], "rel", false, new string[] { "col 1", "col2" }, new string[] { "col1", "col 2" }, false, false); }
private void ReadTest1Check(DataSet ds) { DataSetAssertion.AssertDataSet("dataset", ds, "NewDataSet", 2, 1); DataSetAssertion.AssertDataTable("tbl1", ds.Tables[0], "Table1", 3, 0, 0, 1, 1, 0); DataSetAssertion.AssertDataTable("tbl2", ds.Tables[1], "Table2", 3, 0, 1, 0, 1, 0); DataRelation rel = ds.Relations[0]; DataSetAssertion.AssertDataRelation("rel", rel, "Rel1", false, new string[] { "Column1_3" }, new string[] { "Column2_1" }, true, true); DataSetAssertion.AssertUniqueConstraint("uc", rel.ParentKeyConstraint, "Constraint1", false, new string[] { "Column1_3" }); DataSetAssertion.AssertForeignKeyConstraint("fk", rel.ChildKeyConstraint, "Rel1", AcceptRejectRule.None, Rule.Cascade, Rule.Cascade, new string[] { "Column2_1" }, new string[] { "Column1_3" }); }
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" }); }
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); }