private void SortTest(string property, ListSortDirection direction) { var list = new List <ListElement> { 3, 1, 4, 1, 5, 9 }; var sortedList = direction == ListSortDirection.Ascending ? new List <ListElement> { 1, 1, 3, 4, 5, 9 } : new List <ListElement> { 9, 5, 4, 3, 1, 1 }; var bindingList = new SortableBindingList <ListElement>(list); ((IBindingList)bindingList).ApplySort(ListElement.Property(property), direction); Assert.True(list.SequenceEqual(sortedList, new ListElementComparer())); }
public void SortableBindingList_can_sort_when_list_is_of_derived_type() { var list = new List <DerivedListElement> { new DerivedListElement(3), new DerivedListElement(1), new DerivedListElement(4) }; var sortedList = new List <DerivedListElement> { new DerivedListElement(1), new DerivedListElement(3), new DerivedListElement(4) }; var bindingList = new SortableBindingList <DerivedListElement>(list); ((IBindingList)bindingList).ApplySort(ListElement.Property("Int"), ListSortDirection.Ascending); Assert.True(list.SequenceEqual(sortedList, new ListElementComparer())); }