public void ProcessCallsNextIfHttpContextIsNull()
        {
            HttpContext.Current = null;

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new UserAgentTelemetryProcessor(spy);

            source.Process(new RequestTelemetry());

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

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new UserAgentTelemetryProcessor(spy);

            source.Process(new RequestTelemetry());

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

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new UserAgentTelemetryProcessor(spy);

            source.Process(new RequestTelemetry());

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

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new UserAgentTelemetryProcessor(spy);

            source.Process(new RequestTelemetry());

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

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new UserAgentTelemetryProcessor(spy);

            source.Process(new RequestTelemetry());

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

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new UserAgentTelemetryProcessor(spy);

            source.Process(new RequestTelemetry());

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

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new UserAgentTelemetryProcessor(spy);

            source.UserAgents.Add(new FilterRequest { Value = "\n " });

            source.Process(new RequestTelemetry());

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

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new UserAgentTelemetryProcessor(spy);

            source.UserAgents.Add(new FilterRequest {
                Value = "\n "
            });

            source.Process(new RequestTelemetry());

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

            var spy = new SimpleTelemetryProcessorSpy();

            var source = new UserAgentTelemetryProcessor(spy);

            source.UserAgents.Add(new FilterRequest {
                Value = string.Empty
            });

            source.Process(new RequestTelemetry());

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