public void SetSortDirectionCore() { IBindingList bindingList = SortableBindingListFactory.Create(); PropertyDescriptor propertyDescriptor = PropertyDescriptorHelper.Get(bindingList[0], "Id"); bindingList.ApplySort(propertyDescriptor, ListSortDirection.Descending); ListSortDirection actual = bindingList.SortDirection; ListSortDirection expected = ListSortDirection.Descending; Assert.AreEqual(expected, actual); }
public void Find_ItemNotFound_ReturnMinusOne() { IBindingList bindingList = SortableBindingListFactory.Create(); PropertyDescriptor propertyDescriptor = PropertyDescriptorHelper.Get(bindingList[0], "Address"); bindingList.ApplySort(propertyDescriptor, ListSortDirection.Descending); object key = new GenericComparableAddress("4"); int actual = bindingList.Find(propertyDescriptor, key); int expected = -1; Assert.AreEqual(expected, actual); }
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); }
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); }
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); }
public void IsSorted_FalseWhenNotSorted() { IBindingList bindingList = SortableBindingListFactory.Create(); Assert.IsFalse(bindingList.IsSorted); }