public void it_should_not_execute_code_under_test_once_before_performance_test_if_Warmup_option_is_false() { var numberOfTimesActionIsExecuted = 0; Action action = () => numberOfTimesActionIsExecuted += 1; _chronometer = new Narkhedegs.PerformanceMeasurement.Chronometer(_options, _normalizedMeanCalculatorMock.Object, _timerFactoryMock.Object, _memoryOptimizerMock.Object, _performanceOptimizerMock.Object, _debugModeDetectorMock.Object); _chronometer.Measure(action); Assert.AreEqual(1, numberOfTimesActionIsExecuted); }
public void it_should_assign_the_value_of_options_parameter_to_Options_property_if_options_parameter_is_not_null() { _options = new ChronometerOptions { NumberOfInterations = 10 }; var chronometer = new Narkhedegs.PerformanceMeasurement.Chronometer(_options, _normalizedMeanCalculatorMock.Object, _timerFactoryMock.Object, _memoryOptimizerMock.Object, _performanceOptimizerMock.Object, _debugModeDetectorMock.Object); Assert.AreEqual(chronometer.Options, _options); }
public void it_should_execute_code_under_test_for_value_of_numberOfIterations() { var numberOfTimesActionIsExecuted = 0; Action action = () => numberOfTimesActionIsExecuted += 1; _options = ChronometerOptionsGenerator.Default().WithNumberOfIterations(10); _chronometer = new Narkhedegs.PerformanceMeasurement.Chronometer(_options, _normalizedMeanCalculatorMock.Object, _timerFactoryMock.Object, _memoryOptimizerMock.Object, _performanceOptimizerMock.Object, _debugModeDetectorMock.Object); _chronometer.Measure(action); Assert.AreEqual(10, numberOfTimesActionIsExecuted); }
public void it_should_call_NormalizedMeanCalculator_if_UseNormalizedMean_option_is_true() { Action doNothing = () => { }; _options = ChronometerOptionsGenerator.Default().WithUseNormalizedMean(); _chronometer = new Narkhedegs.PerformanceMeasurement.Chronometer(_options, _normalizedMeanCalculatorMock.Object, _timerFactoryMock.Object, _memoryOptimizerMock.Object, _performanceOptimizerMock.Object, _debugModeDetectorMock.Object); _chronometer.Measure(doNothing); _normalizedMeanCalculatorMock.Verify(calculator => calculator.Calculate(It.IsAny <IEnumerable <double> >()), Times.Once); }
public void it_should_assign_the_value_of_options_parameter_to_Options_property_if_options_parameter_is_not_null () { _options = new ChronometerOptions { NumberOfInterations = 10 }; var chronometer = new Narkhedegs.PerformanceMeasurement.Chronometer(_options, _normalizedMeanCalculatorMock.Object, _timerFactoryMock.Object, _memoryOptimizerMock.Object, _performanceOptimizerMock.Object, _debugModeDetectorMock.Object); Assert.AreEqual(chronometer.Options, _options); }
it_should_not_allow_measurements_if_AllowMeasurementsUnderDebugMode_option_is_false_and_the_current_process_is_in_debug_mode () { _debugModeDetectorMock.Setup(debugModeDetector => debugModeDetector.IsInDebugMode()).Returns(true); Action doNothing = () => { }; _options = ChronometerOptionsGenerator.Default().DoNotAllowMeasurementsUnderDebugMode(); _chronometer = new Narkhedegs.PerformanceMeasurement.Chronometer(_options, _normalizedMeanCalculatorMock.Object, _timerFactoryMock.Object, _memoryOptimizerMock.Object, _performanceOptimizerMock.Object, _debugModeDetectorMock.Object); Assert.Throws <InvalidOperationException>(() => _chronometer.Measure(doNothing)); }
public void SetUp() { _options = ChronometerOptionsGenerator.Default(); _normalizedMeanCalculatorMock = new Mock <INormalizedMeanCalculator>(); _timerFactoryMock = new Mock <ITimerFactory>(); _timerFactoryMock.Setup(timerFactory => timerFactory.Create(It.IsAny <ChronometerOptions>())) .Returns(new FakeTimer()); _memoryOptimizerMock = new Mock <IMemoryOptimizer>(); _performanceOptimizerMock = new Mock <IPerformanceOptimizer>(); _debugModeDetectorMock = new Mock <IDebugModeDetector>(); _debugModeDetectorMock.Setup(debugModeDetector => debugModeDetector.IsInDebugMode()).Returns(false); _chronometer = new Narkhedegs.PerformanceMeasurement.Chronometer(_options, _normalizedMeanCalculatorMock.Object, _timerFactoryMock.Object, _memoryOptimizerMock.Object, _performanceOptimizerMock.Object, _debugModeDetectorMock.Object); }