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

FindTest() private method

private FindTest ( ) : void
return void
        public void FindTest()
        {
            DataView dv = new DataView(_dt);

            IBindingList ib = dv;
            ib.ListChanged += new ListChangedEventHandler(OnListChanged);
            try
            {
                _args = null;
                dv.Sort = "id DESC";
                PropertyDescriptorCollection pds = ((ITypedList)dv).GetItemProperties(null);
                PropertyDescriptor pd = pds.Find("id", false);
                int index = ib.Find(pd, 15);
                Assert.Equal(1, index);

                // negative search
                index = ib.Find(pd, 44);
                Assert.Equal(-1, index);
            }
            finally
            {
                ib.ListChanged -= new ListChangedEventHandler(OnListChanged);
            }
        }