Just to make a quick observation, since I just tried to make such a randomized view using the following code (to get basic unit tests to run in random order):
Action<object>[] tests = new Action<object>[] { delegate { SearchStringByTree(SOURCE, distinctor.Keys, out treeResults, out treeTicks); }, delegate { SearchStringByIndexOf(SOURCE, distinctor.Keys, out indexOfResults, out indexOfTicks); }, delegate { SearchBinaryByTree(Encoding.UTF8.GetBytes(SOURCE), GetBytes(Encoding.UTF8, TERMS), out utf8Results, out utf8Ticks); }, delegate { SearchBinaryByTree(Encoding.UTF8.GetBytes(SOURCE), GetBytes(Encoding.ASCII, TERMS), out asciiResults, out asciiTicks); } }; Random r = new Random(); Array.Sort(tests, delegate { return r.Next(-1, 2); });
I accidentally got the following ArgumentException :
IComparer (or the IComparable methods it relies upon) did not return zero
when Array.Sort called x. CompareTo (x). x: '' x type: 'Action`1'
The IComparer: 'System.Array + FunctorComparer`1 [System.Action`1 [System.Object]]'.
Sort seems to claim equality over elements that are known to be the same (assuming object.ReferenceEquals ), and if Comparer does not return 0 for those that he knows should be equal, it invalidates the whole view.
source share