/// <summary>
 /// Conduct an asynchronous experiment
 /// </summary>
 /// <typeparam name="T">The return type of the experiment</typeparam>
 /// <param name="scientist">The scientist implementation to use</param>
 /// <param name="name">Name of the experiment</param>
 /// <param name="concurrentTasks">Number of tasks to run concurrently</param>
 /// <param name="experiment">Experiment callback used to configure the experiment</param>
 /// <returns>The value of the experiment's control function.</returns>
 public static Task <T> ExperimentAsync <T>(this IScientist scientist, string name, int concurrentTasks, Action <IExperimentAsync <T> > experiment) =>
 scientist.ExperimentAsync <T, T>(
     name,
     concurrentTasks,
     e =>
 {
     e.Clean(NoOpClean);
     experiment(e);
 });
示例#2
0
        public async Task TestMethod1()
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            await _scientist.ExperimentAsync <int>("assert experiment", 2, experiment =>
            {
                experiment.Use(() => DelaySeconds(2));
                experiment.Try(() => DelaySeconds(3));
            });

            stopwatch.Stop();
            var duration = stopwatch.ElapsedMilliseconds;

            Assert.IsTrue((duration < 4000));
        }
 /// <summary>
 /// Conduct an asynchronous experiment
 /// </summary>
 /// <typeparam name="T">The return type of the experiment</typeparam>
 /// <typeparam name="TClean">The clean type for publishing.</typeparam>
 /// <param name="scientist">The scientist implementation to use</param>
 /// <param name="name">Name of the experiment</param>
 /// <param name="experiment">Experiment callback used to configure the experiment</param>
 /// <returns>The value of the experiment's control function.</returns>
 public static Task <T> ExperimentAsync <T, TClean>(this IScientist scientist, string name, Action <IExperimentAsync <T, TClean> > experiment) =>
 scientist.ExperimentAsync(name, 1, experiment);