System.Data.Tests.DataSetTest2.WriteXmlSchema_ForignKeyConstraint C# (CSharp) Method

WriteXmlSchema_ForignKeyConstraint() private method

private WriteXmlSchema_ForignKeyConstraint ( ) : void
return void
        public void WriteXmlSchema_ForignKeyConstraint()
        {
            DataSet ds1 = new DataSet();

            DataTable table1 = ds1.Tables.Add();
            DataTable table2 = ds1.Tables.Add();

            DataColumn col1_1 = table1.Columns.Add("col1", typeof(int));
            DataColumn col2_1 = table2.Columns.Add("col1", typeof(int));

            table2.Constraints.Add("fk", col1_1, col2_1);

            StringWriter sw = new StringWriter();
            ds1.WriteXmlSchema(sw);
            string xml = sw.ToString();

            Assert.True(xml.IndexOf(@"<xs:keyref name=""fk"" refer=""Constraint1"" " +
                        @"msdata:ConstraintOnly=""true"">") != -1, "#1");
        }
DataSetTest2