public void XmlTest6()
{
//Create a parent table and create child tables
MakeParentTable1();
MakeChildTable();
MakeSecondChildTable();
//Relate the parent and the children
MakeDataRelation();
using (FileStream stream = new FileStream(_tempFile, FileMode.Create))
{
_parentTable1.WriteXml(stream, XmlWriteMode.WriteSchema, true);
}
DataTable table = new DataTable();
table.ReadXml(_tempFile);
VerifyTable_WithChildren(table, _parentTable1.TableName, _parentTable1.DataSet);
//Check Properties of First Child Table
DataTable firstChildTable = table.ChildRelations[1].ChildTable;
Assert.Equal(string.Empty, firstChildTable.Namespace);
Assert.Equal("XmlDataSet", firstChildTable.DataSet.DataSetName);
Assert.Equal(3, firstChildTable.Columns.Count);
Assert.Equal(typeof(int), firstChildTable.Columns[0].DataType);
Assert.Equal(typeof(string), firstChildTable.Columns[1].DataType);
Assert.Equal(typeof(int), firstChildTable.Columns[2].DataType);
Assert.Equal(6, firstChildTable.Rows.Count);
Assert.Equal(false, firstChildTable.CaseSensitive);
Assert.Equal("ChildTable", firstChildTable.TableName);
Assert.Equal(string.Empty, firstChildTable.Prefix);
Assert.Equal(2, firstChildTable.Constraints.Count);
Assert.Equal("Constraint1", firstChildTable.Constraints[0].ToString());
Assert.Equal("ParentChild_Relation1", firstChildTable.Constraints[1].ToString());
Assert.Equal(1, firstChildTable.ParentRelations.Count);
Assert.Equal("ParentTable", firstChildTable.ParentRelations[0].ParentTable.TableName);
Assert.Equal(0, firstChildTable.ChildRelations.Count);
Assert.Equal(0, firstChildTable.PrimaryKey.Length);
//Check Properties of Second Child Table
DataTable secondChildTable = table.ChildRelations[0].ChildTable;
Assert.Equal(string.Empty, secondChildTable.Namespace);
Assert.Equal("XmlDataSet", secondChildTable.DataSet.DataSetName);
Assert.Equal(4, secondChildTable.Columns.Count);
Assert.Equal(typeof(int), secondChildTable.Columns[0].DataType);
Assert.Equal(typeof(string), secondChildTable.Columns[1].DataType);
Assert.Equal(typeof(int), secondChildTable.Columns[2].DataType);
Assert.Equal(typeof(int), secondChildTable.Columns[3].DataType);
Assert.Equal(6, secondChildTable.Rows.Count);
Assert.Equal(false, secondChildTable.CaseSensitive);
Assert.Equal("SecondChildTable", secondChildTable.TableName);
Assert.Equal(string.Empty, secondChildTable.Prefix);
Assert.Equal(2, secondChildTable.Constraints.Count);
Assert.Equal("Constraint1", secondChildTable.Constraints[0].ToString());
Assert.Equal("ParentChild_Relation2", secondChildTable.Constraints[1].ToString());
Assert.Equal(1, secondChildTable.ParentRelations.Count);
Assert.Equal("ParentTable", secondChildTable.ParentRelations[0].ParentTable.TableName);
Assert.Equal(0, secondChildTable.ChildRelations.Count);
Assert.Equal(0, secondChildTable.PrimaryKey.Length);
}