public void Test_Sort_MyObjectFull_2() { CompareMyObject cm = new CompareMyObject(); ICollection <MyObject> res, res2 = null; List <MyObject> fullexpected = null; List <MyObject> _MyList = Enumerable.Range(0, 200000).Select(i => new MyObject(i.ToString(), i)).Reverse().ToList(); GC.Collect(); GC.WaitForPendingFinalizers(); using (TimeTracer.TimeTrack("find 10 in a list of 200000")) { res = _MyList.SortFirst(10, cm); } using (TimeTracer.TimeTrack("find 10 parallel in a list of 2000000")) { res2 = _MyList.SortFirstParallel(10, cm); } using (TimeTracer.TimeTrack("full sort a list of 200000")) { fullexpected = _MyList.OrderBy(s => s, cm).ToList(); } res.Count.Should().Be(10); res.Should().Equal(fullexpected.Take(10)); res2.Count.Should().Be(10); res2.Should().Equal(fullexpected.Take(10)); }
public void TestEnumerator() { var cp = new CompareMyObject(); var pqlocal = new PriorityQueue <MyObject>(cp); pqlocal.ItemComparer.Should().Be(cp); //string s; // use a hashtable to check contents of PQ var ht = new HashSet <MyObject>(); for (int i = 0; i < 5; i++) { var ob = new MyObject("item: " + i.ToString(), i * 2); ht.Add(ob); pqlocal.Enqueue(ob); } pqlocal.Should().BeEquivalentTo(ht, "Enumerable PriorityQueue"); }