public void OnEndSetsDurationToPositiveValue()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();
            
            var module = new TestableRequestTrackingTelemetryModule(context);
            module.Initialize(TelemetryConfiguration.CreateDefault());
            module.OnBeginRequest(null);
            module.OnEndRequest(null);

            Assert.IsTrue(context.GetRequestTelemetry().Duration.TotalMilliseconds >= 0);
        }
예제 #2
0
        public void OnEndSetsHttpMethod()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

            var module = new TestableRequestTrackingTelemetryModule(context);

            module.Initialize(TelemetryConfiguration.CreateDefault());
            module.OnBeginRequest(null);
            module.OnEndRequest(null);

            Assert.AreEqual(context.Request.HttpMethod, context.GetRequestTelemetry().HttpMethod);
        }
예제 #3
0
        public void OnEndSetsDurationToPositiveValue()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

            var module = new TestableRequestTrackingTelemetryModule(context);

            module.Initialize(TelemetryConfiguration.CreateDefault());
            module.OnBeginRequest(null);
            module.OnEndRequest(null);

            Assert.IsTrue(context.GetRequestTelemetry().Duration.TotalMilliseconds >= 0);
        }
예제 #4
0
        public void OnEndCreatesRequestTelemetryIfBeginWasNotCalled()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());
                module.OnEndRequest(null);

                Assert.IsNotNull(context.GetRequestTelemetry());
            }
        }
예제 #5
0
        public void OnEndSetsDurationToZeroIfBeginWasNotCalled()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());
                module.OnEndRequest(null);

                Assert.AreEqual(0, context.GetRequestTelemetry().Duration.Ticks);
            }
        }
예제 #6
0
        public void OnEndSetsUrl()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());
                module.OnBeginRequest(null);
                module.OnEndRequest(null);

                Assert.Equal(context.Request.Url, context.GetRequestTelemetry().Url);
            }
        }
예제 #7
0
        public void OnEndSetsResponseCode()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

            context.Response.StatusCode = 401;

            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());
                module.OnBeginRequest(null);
                module.OnEndRequest(null);

                Assert.AreEqual("401", context.GetRequestTelemetry().ResponseCode);
            }
        }
예제 #8
0
        public void OnEndDoesNotOverrideUrl()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());
                module.OnBeginRequest(null);
                var requestTelemetry = context.GetRequestTelemetry();
                requestTelemetry.Url = new Uri("http://test/");

                module.OnEndRequest(null);

                Assert.AreEqual("http://test/", requestTelemetry.Url.OriginalString);
            }
        }
예제 #9
0
        public void OnEndDoesNotOverrideHttpMethod()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());
                module.OnBeginRequest(null);
                var requestTelemetry = context.GetRequestTelemetry();
                requestTelemetry.HttpMethod = "Test";

                module.OnEndRequest(null);

                Assert.AreEqual("Test", requestTelemetry.HttpMethod);
            }
        }
예제 #10
0
        public void OnEndDoesNotOverrideResponseCode()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

            context.Response.StatusCode = 300;

            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());

                module.OnBeginRequest(null);
                var requestTelemetry = context.GetRequestTelemetry();
                requestTelemetry.ResponseCode = "Test";

                module.OnEndRequest(null);

                Assert.Equal("Test", requestTelemetry.ResponseCode);
            }
        }
        public void OnEndSetsResponseCode()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();
            context.Response.StatusCode = 401;

            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());
                module.OnBeginRequest(null);
                module.OnEndRequest(null);

                Assert.AreEqual("401", context.GetRequestTelemetry().ResponseCode);
            }
        }
        public void OnEndSetsHttpMethod()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

            var module = new TestableRequestTrackingTelemetryModule(context);
            module.Initialize(TelemetryConfiguration.CreateDefault());
            module.OnBeginRequest(null);
            module.OnEndRequest(null);

            Assert.Equal(context.Request.HttpMethod, context.GetRequestTelemetry().HttpMethod);
        }
        public void OnEndDoesNotOverrideHttpMethod()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());
                module.OnBeginRequest(null);
                var requestTelemetry = context.GetRequestTelemetry();
                requestTelemetry.HttpMethod = "Test";

                module.OnEndRequest(null);

                Assert.Equal("Test", requestTelemetry.HttpMethod);
            }
        }
        public void OnEndCreatesRequestTelemetryIfBeginWasNotCalled()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());
                module.OnEndRequest(null);

                Assert.IsNotNull(context.GetRequestTelemetry());
            }
        }
        public void OnEndDoesNotOverrideResponseCode()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();
            context.Response.StatusCode = 300;

            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());

                module.OnBeginRequest(null);
                var requestTelemetry = context.GetRequestTelemetry();
                requestTelemetry.ResponseCode = "Test";

                module.OnEndRequest(null);

                Assert.AreEqual("Test", requestTelemetry.ResponseCode);
            }
        }
        public void OnEndDoesNotOverrideUrl()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());
                module.OnBeginRequest(null);
                var requestTelemetry = context.GetRequestTelemetry();
                requestTelemetry.Url = new Uri("http://test/");

                module.OnEndRequest(null);

                Assert.AreEqual("http://test/", requestTelemetry.Url.OriginalString);
            }
        }
        public void OnEndSetsDurationToZeroIfBeginWasNotCalled()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());
                module.OnEndRequest(null);

                Assert.AreEqual(0, context.GetRequestTelemetry().Duration.Ticks);
            }
        }
        public void OnEndSetsUrl()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());
                module.OnBeginRequest(null);
                module.OnEndRequest(null);

                Assert.AreEqual(context.Request.Url, context.GetRequestTelemetry().Url);
            }
        }