/// <summary>
 /// Conduct a synchronous 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="experiment">Experiment callback used to configure the experiment</param>
 /// <returns>The value of the experiment's control function.</returns>
 public static T Experiment <T>(this IScientist scientist, string name, Action <IExperiment <T> > experiment) =>
 scientist.Experiment <T, T>(
     name,
     e =>
 {
     e.Clean(NoOpClean);
     experiment(e);
 });
示例#2
0
        public void Test2()
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            _scientist.Experiment <int>("assert experiment", experiment =>
            {
                experiment.Use(() => DelaySeconds(2).ConfigureAwait(false).GetAwaiter().GetResult());
                experiment.Try(() => DelaySeconds(3).ConfigureAwait(false).GetAwaiter().GetResult());
            });
            stopwatch.Stop();
            var duration = stopwatch.ElapsedMilliseconds;

            Assert.True(duration < 4000);
        }