public void MetricSpace_WhenCombiningKeys_ShouldMatchPattern() { var sut = new MetricSpace(Key1); var metricInfo = new MetricInfo(); sut.Meter(Key2).Send(metricInfo); var result = metricInfo.Key; Assert.Equal($"{Key1}.{Key2}", result); }
public void MetricSpace_WhenUsingDifferntDelimiter_ShouldMatchPattern() { const string delimiter = ";"; var sut = new MetricSpace(Key1); sut.Options.KeysDelimiter = delimiter; var metricInfo = new MetricInfo(); sut.Meter(Key2).Send(metricInfo); var result = metricInfo.Key; Assert.Equal($"{Key1}{delimiter}{Key2}", result); }
public void ActionConditionalTimeScope_WhenConditionIsFalse_ShouldNotSendExecutionTime() { var sut = new MetricSpace("s"); var metricReporter = Substitute.For <IMetricReporter>(); sut.AddReporter(metricReporter); var meter = sut.Meter("x"); var info = new MetricInfo(); info.Data.Add("some-value", "value"); meter.ConditionalTimeScope(info, () => { }, () => false, DurationKey); metricReporter.DidNotReceive().Report(Arg.Any <MetricInfo>()); }
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]); }