internal static void Correctness() { int count = Environment.ProcessorCount * 4; int[] source = Enumerable.Range(0, count).ToArray(); // 0 ... 15. int elementAt = new StaticPartitioner <int>(source).AsParallel().Select(value => value + ComputingWorkload()) .ElementAt(count / 2).WriteLine() // Expected: 8, .WriteLine(); // Actual: 2. int first = new StaticPartitioner <int>(source).AsParallel().Select(value => value + ComputingWorkload()) .First() // Expected: 0. .WriteLine(); // Actual: 3. int last = new StaticPartitioner <int>(source).AsParallel().Select(value => value + ComputingWorkload()) .Last() // Expected: 15. .WriteLine(); // Actual: 13. new StaticPartitioner <int>(source).AsParallel().Select(value => value + ComputingWorkload()) .Take(count / 2) // Expected: 0 ... 7. .WriteLines(); // Actual: 3 2 5 7 10 11 14 15. new StaticPartitioner <int>(source).AsParallel().Select(value => value + ComputingWorkload()) .Skip(count / 2) // Expected: 8 ... 15. .WriteLines(); // Actual: 3 0 7 5 11 10 15 14. new StaticPartitioner <int>(source).AsParallel().Select(value => value + ComputingWorkload()) .TakeWhile(value => value <= count / 2) // Expected: 0 ... 7. .WriteLines(); // Actual: 3 5 8. new StaticPartitioner <int>(source).AsParallel().Select(value => value + ComputingWorkload()) .SkipWhile(value => value <= count / 2) // Expected: 9 ... 15. .WriteLines(); // Actual: 1 3 2 13 5 7 6 11 9 10 15 12 14. new StaticPartitioner <int>(source).AsParallel().Select(value => value + ComputingWorkload()) .Reverse() // Expected: 15 ... 0. .WriteLines(); // Actual: 12 8 4 2 13 9 5 1 14 10 6 0 15 11 7 3. bool sequentialEqual = new StaticPartitioner <int>(source).AsParallel().Select(value => value + ComputingWorkload()) .SequenceEqual(new StaticPartitioner <int>(source).AsParallel()); // Expected: True. sequentialEqual.WriteLine(); // Actual: False. new StaticPartitioner <int>(source).AsParallel().Select(value => value + ComputingWorkload()) .Zip( second: new StaticPartitioner <int>(source).AsParallel(), resultSelector: (a, b) => $"({a}, {b})") // Expected: (0, 0) ... (15, 15). .WriteLines(); // Actual: (3, 8) (0, 12) (1, 0) (2, 4) (6, 9) (7, 13) ... }