Ejemplo n.º 1
0
        public void ApplySort_GenericComparable_Asc()
        {
            IBindingList bindingList = SortableBindingListFactory.Create();

            IList sortedByAddressAscending = new[]
            {
                bindingList[0],
                bindingList[1],
                bindingList[2]
            };

            PropertyDescriptor propertyDescriptor = PropertyDescriptorHelper.Get(bindingList[0], "Address");

            bindingList.ApplySort(propertyDescriptor, ListSortDirection.Ascending);
            AssertSortableBindingList.HaveSameElements(sortedByAddressAscending, bindingList);
        }
Ejemplo n.º 2
0
        public void SortOnPropertiesOfSameType()
        {
            IBindingList bindingList = SortableBindingListFactory.Create();

            IList sortedByFirstNameAscending = new[]
            {
                bindingList[0],
                bindingList[1],
                bindingList[2]
            };

            IList sortedByFirstNameDescending = new[]
            {
                bindingList[2],
                bindingList[1],
                bindingList[0]
            };

            IList sortedByLastNameAscending = new[]
            {
                bindingList[1],
                bindingList[2],
                bindingList[0]
            };

            IList sortedByLastNameDescending = new[]
            {
                bindingList[0],
                bindingList[2],
                bindingList[1]
            };

            PropertyDescriptor firstNameProperty = PropertyDescriptorHelper.Get(bindingList[0], "FirstName");
            PropertyDescriptor lastNameProperty  = PropertyDescriptorHelper.Get(bindingList[0], "LastName");

            bindingList.ApplySort(lastNameProperty, ListSortDirection.Descending);
            AssertSortableBindingList.HaveSameElements(sortedByLastNameDescending, bindingList);

            bindingList.ApplySort(firstNameProperty, ListSortDirection.Descending);
            AssertSortableBindingList.HaveSameElements(sortedByFirstNameDescending, bindingList);

            bindingList.ApplySort(firstNameProperty, ListSortDirection.Ascending);
            AssertSortableBindingList.HaveSameElements(sortedByFirstNameAscending, bindingList);

            bindingList.ApplySort(lastNameProperty, ListSortDirection.Ascending);
            AssertSortableBindingList.HaveSameElements(sortedByLastNameAscending, bindingList);
        }
Ejemplo n.º 3
0
        public void ReusePropertyComparerIfSortIsAppliedForSecondTime()
        {
            IBindingList bindingList = SortableBindingListFactory.Create();

            IList sortedByAddressDescneding = new[]
            {
                bindingList[2],
                bindingList[1],
                bindingList[0]
            };

            PropertyDescriptor propertyDescriptor = PropertyDescriptorHelper.Get(bindingList[0], "Address");

            bindingList.ApplySort(propertyDescriptor, ListSortDirection.Descending);
            bindingList.ApplySort(propertyDescriptor, ListSortDirection.Descending);
            AssertSortableBindingList.HaveSameElements(sortedByAddressDescneding, bindingList);
        }