public void DataMeterActionConditionalTimeScope_WhenConditionIsFalse_ShouldNotSendExecutionTime() { var sut = new MetricSpace("s"); var metricReporter = Substitute.For <IMetricReporter>(); sut.AddReporter(metricReporter); var meter = sut.DataMeter("x"); meter.Data.Add("some-value", "value"); meter.ConditionalTimeScope(() => { }, () => false, DurationKey); metricReporter.DidNotReceive().Report(Arg.Any <MetricInfo>()); }
public void DataMemberActionConditionalTimeScope_WhenConditionIsTrue_ShouldSendExecutionTime() { var sut = new MetricSpace("s"); var recorder = new ReportsRecorder(); sut.AddReporter(recorder); var meter = sut.DataMeter("x"); meter.Data.Add("some-value", "value"); meter.ConditionalTimeScope(() => { }, () => true, DurationKey); Assert.Contains(DurationKey, recorder.Last.Data.Keys); Assert.IsType <double>(recorder.Last.Data[DurationKey]); }
public void DateMeterTimeScope_WhenUsingTimeScope_ShouldSendExecutionTime() { var sut = new MetricSpace("s"); var recorder = new ReportsRecorder(); sut.AddReporter(recorder); var meter = sut.DataMeter("x"); meter.AddData("some-value", "value"); using (meter.TimeScope(DurationKey)) { } Assert.Contains(DurationKey, recorder.Last.Data.Keys); Assert.IsType <double>(recorder.Last.Data[DurationKey]); }
public void TimeScope_WhenUsingTimeScopeAction_ShouldSendExecutionTime() { var sut = new MetricSpace("s"); var recorder = new ReportsRecorder(); sut.AddReporter(recorder); var meter = sut.Meter("x"); var info = new MetricInfo(); info.Data.Add("some-value", "value"); meter.TimeScope(info, () => { }, DurationKey); Assert.Contains(DurationKey, recorder.Last.Data.Keys); Assert.IsType <TimeSpan>(recorder.Last.Data[DurationKey]); }
public void ConditionalTimeScope_WhenConditionIsTrue_ShouldSendExecutionTime() { var sut = new MetricSpace("s"); var recorder = new ReportsRecorder(); sut.AddReporter(recorder); var meter = sut.Meter("x"); var info = new MetricInfo(); info.Data.Add("some-value", "value"); using (meter.ConditionalTimeScope(info, () => true, DurationKey)) { } Assert.Contains(DurationKey, recorder.Last.Data.Keys); Assert.IsType <TimeSpan>(recorder.Last.Data[DurationKey]); }