예제 #1
0
        public void EndRequest_should_stop_requesttimer()
        {
            var requestTimer = Substitute.For <IRequestTimer>();
            var context      = Substitute.For <IMetricTaskContext>();

            var task = new RequestTimingTask(context, requestTimer);

            //Act
            task.EndRequest();

            //Assert
            requestTimer.Received().StopRequestTimer();
        }
예제 #2
0
        public void EndRequest_should_add_request_time()
        {
            long requestTime  = 123;
            var  requestTimer = Substitute.For <IRequestTimer>();

            requestTimer.GetRequestMilliseconds().Returns(requestTime);

            var context         = Substitute.For <IMetricTaskContext>();
            var metricsResponse = Substitute.For <IMetricsResponse>();

            context.MetricsResponse.Returns(metricsResponse);

            var task = new RequestTimingTask(context, requestTimer);

            //Act
            task.EndRequest();

            //Assert
            metricsResponse.Received()
            .AddMetric(Arg.Is("request-time"), Arg.Any <string>(), requestTime, Arg.Any <MetricType>());
        }