public void ConstructorSetsOnBeginAsAHanderForEvent2()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();
            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());
                WebEventsPublisher.Log.OnEnd();

                Assert.IsNotNull(context.GetRequestTelemetry());
            }
        }
        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);
        }
예제 #3
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);
        }
예제 #4
0
        public void ConstructorSetsOnBeginAsAHanderForEvent2()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

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

                Assert.IsNotNull(context.GetRequestTelemetry());
            }
        }
        public void OnEndCreatesRequestTelemetryIfBeginWasNotCalled()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();

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

                Assert.IsNotNull(context.GetRequestTelemetry());
            }
        }
예제 #6
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);
        }
예제 #7
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());
            }
        }
예제 #8
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);
            }
        }
예제 #9
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);
            }
        }
예제 #10
0
        public void RequestIdIsAvailableAfterOnBegin()
        {
            var context          = HttpModuleHelper.GetFakeHttpContext();
            var requestTelemetry = context.CreateRequestTelemetryPrivate();

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

                Assert.IsTrue(!string.IsNullOrEmpty(requestTelemetry.Id));
            }
        }
        public void RequestIdIsAvailableAfterOnBegin()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();
            var requestTelemetry = context.CreateRequestTelemetryPrivate();
            
            using (var module = new TestableRequestTrackingTelemetryModule(context))
            {
                module.Initialize(TelemetryConfiguration.CreateDefault());
                module.OnBeginRequest(null);

                Assert.IsTrue(!string.IsNullOrEmpty(requestTelemetry.Id));
            }
        }
        public void OnBeginRequestSetsTimeIfItWasNotAssignedBefore()
        {
            var context = HttpModuleHelper.GetFakeHttpContext();
            var requestTelemetry = context.CreateRequestTelemetryPrivate();
            requestTelemetry.StartTime = default(DateTimeOffset);

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

                Assert.AreNotEqual(default(DateTimeOffset), requestTelemetry.Timestamp);
            }
        }
예제 #13
0
        public void OnBeginRequestSetsTimeIfItWasNotAssignedBefore()
        {
            var context          = HttpModuleHelper.GetFakeHttpContext();
            var requestTelemetry = context.CreateRequestTelemetryPrivate();

            requestTelemetry.StartTime = default(DateTimeOffset);

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

                Assert.AreNotEqual(default(DateTimeOffset), requestTelemetry.Timestamp);
            }
        }
예제 #14
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);
            }
        }
예제 #15
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);
            }
        }
예제 #16
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);
            }
        }
예제 #17
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 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 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);
            }
        }
        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 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 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);
            }
        }