public void ProcessCallsNextIfRequestFailed()
        {
            HttpContext.Current = HttpModuleHelper.GetFakeHttpContextForFailedRequest();

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new HandlerTelemetryProcessor(spy);

            source.Process(new RequestTelemetry());

            Assert.AreEqual(1, spy.ReceivedCalls);
        }
 public void ConstructorThrowsArgumentNullExceptionIfNextIsNull()
 {
     try
     {
         var source = new HandlerTelemetryProcessor(null);
         Assert.Fail("Expected ArgumentNullException to be thrown");
     }
     catch (ArgumentNullException e)
     {
         Assert.AreEqual("next", e.ParamName);
     }
 }
        public void ProcessCallsNextIfHttpContextIsNull()
        {
            HttpContext.Current = null;

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new HandlerTelemetryProcessor(spy);

            source.Process(new RequestTelemetry());

            Assert.AreEqual(1, spy.ReceivedCalls);
        }
        public void ProcessCallsNextIfRequestFailed()
        {
            HttpContext.Current = HttpModuleHelper.GetFakeHttpContextForFailedRequest();

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new HandlerTelemetryProcessor(spy);

            source.Process(new RequestTelemetry());

            Assert.AreEqual(1, spy.ReceivedCalls);
        }
        public void ProcessCallsNextIfHttpContextIsNull()
        {
            HttpContext.Current = null;

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new HandlerTelemetryProcessor(spy);

            source.Process(new RequestTelemetry());

            Assert.AreEqual(1, spy.ReceivedCalls);
        }
 public void ConstructorThrowsArgumentNullExceptionIfNextIsNull()
 {
     try
     {
         var source = new HandlerTelemetryProcessor(null);
         Assert.Fail("Expected ArgumentNullException to be thrown");
     }
     catch (ArgumentNullException e)
     {
         Assert.AreEqual("next", e.ParamName);
     }
 }
        public void ProcessReturnsIfSuccessfulRequestHandlerIsFilteredByDefault()
        {
            HttpContext.Current = HttpModuleHelper.GetFakeHttpContext(new Dictionary<string, string> { { "User-Agent", "a" } });
            HttpContext.Current.Handler = new AssemblyResourceLoader();

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new HandlerTelemetryProcessor(spy);
            source.Handlers.Add(new FilterRequest { Value = "System.Web.Handlers.AssemblyResourceLoader" });

            source.Process(new RequestTelemetry());

            Assert.AreEqual(0, spy.ReceivedCalls);
        }
        public void ProcessCallsNextIfSuccessfulRequestHandlerIsNotFiltered()
        {
            HttpContext.Current = HttpModuleHelper.GetFakeHttpContext(new Dictionary<string, string> { { "User-Agent", "a" } });
            HttpContext.Current.Handler = new AssemblyResourceLoader();

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new HandlerTelemetryProcessor(spy);
            source.Handlers.Add(new FilterRequest { Value = "Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModuleTest+FakeHttpHandler" });

            source.Process(new RequestTelemetry());

            Assert.AreEqual(1, spy.ReceivedCalls);
        }
        public void ProcessReturnsIfSuccessfulRequestHandlerIsFilteredByDefault()
        {
            HttpContext.Current = HttpModuleHelper.GetFakeHttpContext(new Dictionary <string, string> {
                { "User-Agent", "a" }
            });
            HttpContext.Current.Handler = new AssemblyResourceLoader();

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new HandlerTelemetryProcessor(spy);

            source.Handlers.Add(new FilterRequest {
                Value = "System.Web.Handlers.AssemblyResourceLoader"
            });

            source.Process(new RequestTelemetry());

            Assert.AreEqual(0, spy.ReceivedCalls);
        }
        public void ProcessCallsNextIfSuccessfulRequestHandlerIsNotFiltered()
        {
            HttpContext.Current = HttpModuleHelper.GetFakeHttpContext(new Dictionary <string, string> {
                { "User-Agent", "a" }
            });
            HttpContext.Current.Handler = new AssemblyResourceLoader();

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new HandlerTelemetryProcessor(spy);

            source.Handlers.Add(new FilterRequest {
                Value = "Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModuleTest+FakeHttpHandler"
            });

            source.Process(new RequestTelemetry());

            Assert.AreEqual(1, spy.ReceivedCalls);
        }