public void AscendingSort() { int[] intArr = { 45, 23, 57, 56, 11, 87, 94, 44 }; SortedBindingList <int> sortedList = new SortedBindingList <int>(intArr); sortedList.ListChanged += new ListChangedEventHandler(sortedList_ListChanged); Assert.AreEqual(false, sortedList.IsSorted); Assert.AreEqual(56, intArr[3]); sortedList.ApplySort("", ListSortDirection.Ascending); Assert.AreEqual(44, sortedList[2]); Assert.AreEqual(8, sortedList.Count); Assert.AreEqual(true, sortedList.Contains(56)); Assert.AreEqual(4, sortedList.IndexOf(56)); Assert.AreEqual(true, sortedList.IsReadOnly); Assert.AreEqual(true, sortedList.IsSorted); foreach (int item in sortedList) { Console.WriteLine(item.ToString()); } sortedList.RemoveSort(); Assert.AreEqual(false, sortedList.IsSorted); Assert.AreEqual(56, sortedList[3]); // This list dowes not support searching Assert.IsFalse(sortedList.SupportsSearching); // and Find should return -1 because underlying list dows not implement IBindingList Assert.AreEqual(-1, sortedList.Find("", 56)); }
public void AscendingSort() { int[] intArr = { 45, 23, 57, 56, 11, 87, 94, 44 }; SortedBindingList<int> sortedList = new SortedBindingList<int>(intArr); sortedList.ListChanged += new ListChangedEventHandler(sortedList_ListChanged); Assert.AreEqual(false, sortedList.IsSorted); Assert.AreEqual(56, intArr[3]); sortedList.ApplySort("", ListSortDirection.Ascending); Assert.AreEqual(44, sortedList[2]); Assert.AreEqual(8, sortedList.Count); Assert.AreEqual(true, sortedList.Contains(56)); Assert.AreEqual(4, sortedList.IndexOf(56)); Assert.AreEqual(true, sortedList.IsReadOnly); Assert.AreEqual(true, sortedList.IsSorted); foreach (int item in sortedList) { Console.WriteLine(item.ToString()); } sortedList.RemoveSort(); Assert.AreEqual(false, sortedList.IsSorted); Assert.AreEqual(56, sortedList[3]); // This list dowes not support searching Assert.IsFalse(sortedList.SupportsSearching); // and Find should return -1 because underlying list dows not implement IBindingList Assert.AreEqual(-1, sortedList.Find("", 56)); }