예제 #1
0
        public void OnEndAddsFladInHttpContext()
        {
            var httpApplication = HttpModuleHelper.GetFakeHttpApplication();

            this.module.Invoke("OnEndRequest", new[] { typeof(object), typeof(EventArgs) }, new object[] { httpApplication, null }, CultureInfo.InvariantCulture);

            Assert.IsNotNull(httpApplication.Context.Items[RequestTrackingConstants.EndRequestCallFlag]);
        }
        public void GetRequestTelemetryReturnsRequestTelemetryFromItems()
        {
            var expected = new RequestTelemetry();

            var context = HttpModuleHelper.GetFakeHttpContextBase();

            context.ApplicationInstance = HttpModuleHelper.GetFakeHttpApplication();
            context.ApplicationInstance.Context.Items.Add(RequestTrackingConstants.RequestTelemetryItemName, expected);

            var actual = context.GetRequestTelemetry();

            Assert.AreSame(expected, actual);
        }
예제 #3
0
        public void OnEndGeneratesEventsOnlyFromOneModuleInstanceIfItSharesSameHttpContext()
        {
            var httpApplication = HttpModuleHelper.GetFakeHttpApplication();

            using (var listener = new TestEventListener())
            {
                listener.EnableEvents(WebEventsPublisher.Log, EventLevel.LogAlways, (EventKeywords)AllKeywords);

                this.module.Invoke("OnEndRequest", new[] { typeof(object), typeof(EventArgs) }, new object[] { httpApplication, null }, CultureInfo.InvariantCulture);
                this.module2.Invoke("OnEndRequest", new[] { typeof(object), typeof(EventArgs) }, new object[] { httpApplication, null }, CultureInfo.InvariantCulture);

                var count = listener.Messages.Count();
                Assert.AreEqual(2, count); // OnEnd and OnError
            }
        }
예제 #4
0
        public void OnEndGeneratesWebEventsOnErrorEvent()
        {
            using (var listener = new TestEventListener())
            {
                listener.EnableEvents(WebEventsPublisher.Log, EventLevel.LogAlways, (EventKeywords)AllKeywords);

                this.module.Invoke("OnEndRequest", new[] { typeof(object), typeof(EventArgs) }, new object[] { HttpModuleHelper.GetFakeHttpApplication(), null }, CultureInfo.InvariantCulture);

                var messages = listener.Messages.OrderBy(_ => _.EventId).ToList();
                Assert.AreEqual(3, messages[1].EventId);
            }
        }
예제 #5
0
        public void OnBeginGeneratesWebEventsOnBeginEvent()
        {
            using (var listener = new TestEventListener())
            {
                listener.EnableEvents(WebEventsPublisher.Log, EventLevel.LogAlways, (EventKeywords)AllKeywords);

                this.module.Invoke("OnBeginRequest", new[] { typeof(object), typeof(EventArgs) }, new object[] { HttpModuleHelper.GetFakeHttpApplication(), null }, CultureInfo.InvariantCulture);

                var firstEvent = listener.Messages.FirstOrDefault();
                Assert.IsNotNull(firstEvent);
                Assert.AreEqual(1, firstEvent.EventId);
            }
        }