public void Should_exit_on_first_iteration_where_Benchmark_throws_Exception()
        {
            var  iterationCount             = 0;
            var  expectedIterationCount     = 1;
            bool finalOutputCalled          = false;
            IBenchmarkInvoker faultyInvoker = new ActionBenchmarkInvoker("ExceptionThrower",
                                                                         context =>
            {
                throw new Exception("poorly written spec");
            });

            IBenchmarkOutput faultyOutput = new ActionBenchmarkOutput(
                (report, isWarmup) =>
            {
                iterationCount++;     //should run exactly once during pre-warmup
                Assert.True(report.IsFaulted);
            }, results =>
            {
                finalOutputCalled = true;
                Assert.True(results.Data.IsFaulted);
            });

            var benchmark = new Benchmark(_faultySettings, faultyInvoker, faultyOutput);

            benchmark.Run();
            benchmark.Finish();
            Assert.Equal(expectedIterationCount, iterationCount);
            Assert.True(finalOutputCalled);
        }
Пример #2
0
 public BenchmarkWarmupSpecs()
 {
     _benchmarkMethods = new ActionBenchmarkInvoker(GetType().Name, BenchmarkSetupMethod, BenchmarkTestMethod,
                                                    ActionBenchmarkInvoker.NoOp);
 }