System.Data.Tests.DataViewManagerTest.Ctor C# (CSharp) Method

Ctor() private method

private Ctor ( ) : void
return void
        public void Ctor()
        {
            string defaultString = "<DataViewSettingCollectionString></DataViewSettingCollectionString>";
            string current = @"<DataViewSettingCollectionString><table2-1 Sort="""" RowFilter="""" RowStateFilter=""CurrentRows""/></DataViewSettingCollectionString>";
            string deleted = @"<DataViewSettingCollectionString><table2-1 Sort="""" RowFilter="""" RowStateFilter=""Deleted""/></DataViewSettingCollectionString>";

            DataViewManager m = new DataViewManager(null);
            Assert.Null(m.DataSet);
            Assert.Equal("", m.DataViewSettingCollectionString);
            Assert.NotNull(m.DataViewSettings);
            DataSet ds = new DataSet("ds");
            m.DataSet = ds;
            Assert.Equal(defaultString, m.DataViewSettingCollectionString);

            DataSet ds2 = new DataSet("ds2");
            Assert.Equal(defaultString, ds.DefaultViewManager.DataViewSettingCollectionString);
            DataTable dt2_1 = new DataTable("table2-1");
            dt2_1.Namespace = "urn:foo"; // It is ignored though.
            ds2.Tables.Add(dt2_1);
            m.DataSet = ds2;
            Assert.Equal(current, m.DataViewSettingCollectionString);

            // Note that " Deleted " is trimmed.
            m.DataViewSettingCollectionString = @"<DataViewSettingCollectionString><table2-1 Sort='' RowFilter='' RowStateFilter=' Deleted '/></DataViewSettingCollectionString>";
            Assert.Equal(deleted, m.DataViewSettingCollectionString);

            m.DataSet = ds2; //resets modified string.
            Assert.Equal(current, m.DataViewSettingCollectionString);

            m.DataViewSettingCollectionString = @"<DataViewSettingCollectionString><table2-1 Sort='' RowFilter='' RowStateFilter='Deleted'/></DataViewSettingCollectionString>";
            // it does not clear anything.
            m.DataViewSettingCollectionString = "<DataViewSettingCollectionString/>";
            Assert.Equal(deleted, m.DataViewSettingCollectionString);

            // text node is not rejected (ignored).
            // RowFilter is not examined.
            m.DataViewSettingCollectionString = "<DataViewSettingCollectionString>blah<table2-1 RowFilter='a=b' ApplyDefaultSort='true' /></DataViewSettingCollectionString>";
            // LAMESPEC: MS.NET ignores ApplyDefaultSort.
            //			Assert.Equal (@"<DataViewSettingCollectionString><table2-1 Sort="""" RowFilter=""a=b"" RowStateFilter=""Deleted""/></DataViewSettingCollectionString>", m.DataViewSettingCollectionString);
        }