public void FastParallelLoop(int?maxThreads)
 {
     FastParallel.Loop(0, maxThreads, _ => Assert.Fail("When count is empty, no action should be called"));
     foreach (var count in Enumerable.Range(1, 20))
     {
         var executed = new ConcurrentBag <int>();
         FastParallel.Loop(count, maxThreads, index =>
         {
             if (executed.Contains(index))
             {
                 Assert.Fail($"Action for index {index} has been called already.");
             }
             executed.Add(index);
         });
         var expected = Enumerable.Range(0, count).ToArray();
         var actual   = executed.ToArray();
         Array.Sort(actual);
         Assert.AreEqual(expected, actual, $"count = {count}: The set of executed actions is wrong");
     }
 }
 // maxThreads == null should run a plain vanilla for loop.
 public void FastParallelLoopErrors()
 {
     Assert.Throws <ArgumentException>(() => FastParallel.Loop(0, 0, i => { }));
     Assert.Throws <ArgumentNullException>(() => FastParallel.Loop(0, 0, null));
 }