public void CopiesAllElementsFromList() { IList <Person> persons = SortableBindingListFactory.GetPersons(); SortableBindingList <Person> list = new SortableBindingList <Person>(persons); Assert.AreEqual(persons.Count, list.Count); }
public void IsSorted_TrueWhenSorted() { IBindingList bindingList = SortableBindingListFactory.Create(); PropertyDescriptor propertyDescriptor = PropertyDescriptorHelper.Get(bindingList[0], "Id"); bindingList.ApplySort(propertyDescriptor, ListSortDirection.Ascending); Assert.IsTrue(bindingList.IsSorted); }
public void RemoveSort_SetSortPropertyToNull() { IBindingList bindingList = SortableBindingListFactory.Create(); PropertyDescriptor propertyDescriptor = PropertyDescriptorHelper.Get(bindingList[0], "Id"); bindingList.ApplySort(propertyDescriptor, ListSortDirection.Ascending); bindingList.RemoveSort(); Assert.IsNull(bindingList.SortProperty); }
public void RemoveSort_ReturnFalseForIsSorted() { IBindingList bindingList = SortableBindingListFactory.Create(); PropertyDescriptor propertyDescriptor = PropertyDescriptorHelper.Get(bindingList[0], "Id"); bindingList.ApplySort(propertyDescriptor, ListSortDirection.Ascending); bindingList.RemoveSort(); Assert.IsFalse(bindingList.IsSorted); }
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); }