예제 #1
0
        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>());
        }
예제 #2
0
        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]);
        }
예제 #3
0
        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]);
        }