System.Data.Tests.DataTableReaderTest.SchemaTest C# (CSharp) Method

SchemaTest() private method

private SchemaTest ( ) : void
return void
        public void SchemaTest()
        {
            DataTable another = new DataTable("another");
            another.Columns.Add("x", typeof(string));

            another.Rows.Add(new object[] { "test 1" });
            another.Rows.Add(new object[] { "test 2" });
            another.Rows.Add(new object[] { "test 3" });

            DataTableReader reader = new DataTableReader(new DataTable[] { _dt, another });
            try
            {
                DataTable schema = reader.GetSchemaTable();

                Assert.Equal(_dt.Columns.Count, schema.Rows.Count);
                Assert.Equal(_dt.Columns[1].DataType.ToString(), schema.Rows[1]["DataType"].ToString());

                reader.NextResult(); //schema should change here
                schema = reader.GetSchemaTable();

                Assert.Equal(another.Columns.Count, schema.Rows.Count);
                Assert.Equal(another.Columns[0].DataType.ToString(), schema.Rows[0]["DataType"].ToString());
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();
            }
        }