public ISynchronizedRunner <T> Create(SynchronisationTestCase testCase, Action <T> job)
 {
     return(testCase switch
     {
         SynchronisationTestCase.ManualReset => null,
         _ => new AutoResetSynchronizedRunner <T>(job),
     });
        /// <summary>
        /// Helper function to manipulate different case of synchronization.
        /// </summary>
        /// <param name="testCase">The synchronization case to be tested.
        /// See <see cref="SynchronisationTestCase"/> for an enumeration of those cases.</param>
        private static void RunCountWithSynchronization(SynchronisationTestCase testCase)
        {
            const int totalIteration = 10;
            const int expectedCount  = (totalIteration * (totalIteration + 1)) / 2;
            var       factory        = new SynchronizedRunnerFactory <int>();
            var       count          = 0;
            var       runner         = factory.Create(testCase, i => count += i);

            try
            {
                for (int idx = 1; idx <= totalIteration; idx++)
                {
                    runner.SetData(idx);
                }
            }
            finally
            {
                ((IDisposable)runner).Dispose();
            }
            Assert.Equal(expectedCount, count);
        }