public void MultipleColumnsWithDuplicateValuesMixedDirection(SortDirection direction1, SortDirection direction2, string column1, string column2, string expected0, string expected1, string expected2) { MultiLevelComparer <TestClass> comparer = new MultiLevelComparer <TestClass>(); comparer.AddColumn(column1, direction1); comparer.AddColumn(column2, direction2); dupClasses.Sort(comparer); Assert.AreEqual(expected0, dupClasses[0].Name); Assert.AreEqual(expected1, dupClasses[1].Name); Assert.AreEqual(expected2, dupClasses[2].Name); }
public void SortByAddColumnNoDirection(string column, string expected0, string expected1, string expected2) { MultiLevelComparer <TestClass> comparer = new MultiLevelComparer <TestClass>(); comparer.AddColumn(column); list.Sort(comparer); Assert.AreEqual(expected0, list[0].Name); Assert.AreEqual(expected1, list[1].Name); Assert.AreEqual(expected2, list[2].Name); }
public void SpeedTest() { List <TestClass> bigList = new List <TestClass>(); CryptoRandom random = new CryptoRandom("{A:10}"); for (int i = 0; i < 100000; i++) { bigList.Add(new TestClass(i, random.Generate(), DateTime.Now)); } CodeTimer timer = CodeTimer.Start(); MultiLevelComparer <TestClass> comparer = new MultiLevelComparer <TestClass>(); comparer.AddColumn("Id", SortDirection.Ascending); comparer.AddColumn("Name", SortDirection.Descending); bigList.Sort(comparer); Console.WriteLine("Sorted in {0} ms", CodeTimer.Stop(timer).TotalMilliseconds); }