System.Data.Tests.DataViewTest_IBindingList.TestIfCorrectIndexIsUsed C# (CSharp) Method

TestIfCorrectIndexIsUsed() private method

private TestIfCorrectIndexIsUsed ( ) : void
return void
        public void TestIfCorrectIndexIsUsed()
        {
            DataTable table = new DataTable();
            table.Columns.Add("id", typeof(int));

            table.Rows.Add(new object[] { 1 });
            table.Rows.Add(new object[] { 2 });
            table.Rows.Add(new object[] { 3 });
            table.Rows.Add(new object[] { 4 });

            DataView dv = new DataView(table);

            dv.Sort = "[id] DESC";

            // for the new view, the index thats chosen, shud be different from the the one
            // created for the older view.
            dv = new DataView(table);
            IBindingList ib = dv;
            PropertyDescriptorCollection pds = ((ITypedList)dv).GetItemProperties(null);
            PropertyDescriptor pd = pds.Find("id", false);
            int index = ib.Find(pd, 4);
            Assert.Equal(3, index);
        }
    }