public void should_ignore_incorrect_codeRRContext()
        {
            var context = new ErrorReporterContext(this, new Exception());

            var sut    = new QueryStringProvider();
            var result = sut.Collect(context);

            result.Should().BeNull();
        }
Exemplo n.º 2
0
 public PhoneManager(ICookieProvider cookieProvider, IRepository repository, QueryStringProvider querystringProvider, ReferrerProvider referrerProvider, ISessionProvider sessionProvider, IUmbracoProvider umbracoProvider)
 {
     _cookieProvider      = cookieProvider;
     _repository          = repository;
     _querystringProvider = querystringProvider;
     _referrerProvider    = referrerProvider;
     _sessionProvider     = sessionProvider;
     _umbracoProvider     = umbracoProvider;
 }
Exemplo n.º 3
0
 public PhoneManagerAppParamHolder(CookieHolder cookieHolder, string repositoryTestPhoneManagerData, NameValueCollection queryStringCollection, string referrerString, OutputModel sessionModel, string umbracoCurrentPageId)
 {
     CookieProvider      = CookieProvider(cookieHolder).Object;
     RepositoryProvider  = Repository(repositoryTestPhoneManagerData);
     QueryStringProvider = new QueryStringProvider(QueryStringImplementation(queryStringCollection).Object);
     ReferrerProvider    = new ReferrerProvider(ReferrerImplementation(referrerString).Object);
     SessionProvider     = SessionProvider(sessionModel).Object;
     UmbracoProvider     = UmbracoProvider(umbracoCurrentPageId).Object;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Processes the current request to find a relevant phone number to output
 /// </summary>
 public PhoneManager()
 {
     // default providers/repository
     _cookieProvider      = new CookieProvider(new HttpContextCookieImplementation());
     _repository          = new XPathRepository();
     _querystringProvider = new QueryStringProvider(new HttpContextQueryStringImplementation());
     _referrerProvider    = new ReferrerProvider(new HttpContextReferrerImplementation());
     _sessionProvider     = new SessionProvider();
     _umbracoProvider     = new UmbracoProvider();
 }
        public void should_return_null_when_the_collection_is_empty()
        {
            var httpContext = Substitute.For <HttpContextBase>();
            var context     = new AspNetContext(this, new Exception(), httpContext);

            httpContext.Request.QueryString.Returns(new NameValueCollection());

            var sut    = new QueryStringProvider();
            var result = sut.Collect(context);

            result.Should().BeNull();
        }
        public void QueryStringProvider_GetCleansedQueryStrings_WithNullData_ReturnsNotNull()
        {
            // Arrange
            var mockQueryStringProviderSource = MockProviders.QueryStringImplementation(null);

            var criteria = new QueryStringProvider(mockQueryStringProviderSource.Object);

            // Act
            var results = criteria.GetQueryStrings();

            // Assert
            Assert.IsNotNull(results);
        }
        public void should_include_included_items()
        {
            var httpContext = Substitute.For <HttpContextBase>();
            var context     = new AspNetMvcContext(this, new Exception(), httpContext);
            var items       = new NameValueCollection
            {
                { "MyKey", "Value" }
            };

            httpContext.Request.QueryString.Returns(items);

            var sut    = new QueryStringProvider();
            var result = sut.Collect(context);

            result.Property("MyKey").Should().Be("Value");
        }
        public void QueryStringProvider_GetCleansedQueryStrings_WithDangerousData_ReturnsTrue()
        {
            // Arrange
            var mockQueryStringProviderSource = MockProviders.QueryStringImplementation(new NameValueCollection
            {
                { "dummykey", " 'or 1 = 1'" }
            });

            var criteria = new QueryStringProvider(mockQueryStringProviderSource.Object);

            // Act
            var results = criteria.GetQueryStrings();

            // Assert
            Assert.IsTrue(results.Count == 1);
            Assert.IsTrue(results.GetKey(0) == "dummykey");
            Assert.IsTrue(results.GetValues("dummykey").First() == "or11");
        }
        public void QueryStringProvider_GetCleansedQueryStrings_WithValidData_ReturnsTrue()
        {
            // Arrange
            var mockQueryStringProviderSource = MockProviders.QueryStringImplementation(new NameValueCollection
            {
                { MockConstants.DefaultData.DefaultCampaignQuerystringKey, MockConstants.MockTestPhoneNumberData.CampaignCode }
            });

            var criteria = new QueryStringProvider(mockQueryStringProviderSource.Object);

            // Act
            var results = criteria.GetQueryStrings();

            // Assert
            Assert.IsTrue(results.Count == 1);
            Assert.IsTrue(results.GetKey(0) == MockConstants.DefaultData.DefaultCampaignQuerystringKey);
            Assert.IsTrue(results.GetValues(MockConstants.DefaultData.DefaultCampaignQuerystringKey).Contains(MockConstants.MockTestPhoneNumberData.CampaignCode));
        }