Ejemplo n.º 1
0
        public void CountryPersonalisationGroupCriteria_UsingCloudFlareCdnHeaderCountryCodeProvider_MatchesVisitor_WithEmptyDefinition_ThrowsException()
        {
            // Arrange
            var mockRequestHeadersProvider = MockRequestHeadersProvider();
            var countryCodeProvider        = new CdnHeaderCountryCodeProvider(mockRequestHeadersProvider.Object);
            var criteria = new CountryPersonalisationGroupCriteria(countryCodeProvider);

            // Act
            criteria.MatchesVisitor((string)null);
        }
        public void CountryPersonalisationGroupCriteria_UsingCloudFlareCdnHeaderCountryCodeProvider_MatchesVisitor_WithEmptyDefinition_ThrowsException()
        {
            // Arrange
            var config = Options.Create(new PersonalisationGroupsConfig());
            var mockRequestHeadersProvider = MockRequestHeadersProvider();
            var countryCodeProvider        = new CdnHeaderCountryCodeProvider(config, mockRequestHeadersProvider.Object);
            var criteria = new CountryPersonalisationGroupCriteria(countryCodeProvider);

            // Act
            Assert.Throws <ArgumentNullException>(() => criteria.MatchesVisitor(null));
        }
Ejemplo n.º 3
0
        public void CountryPersonalisationGroupCriteria_UsingCloudFlareCdnHeaderCountryCodeProvider_MatchesVisitor_WithValidDefinitionForCouldNotBeLocatedWhenCanLocate_ReturnsFalse()
        {
            // Arrange
            var mockRequestHeadersProvider = MockRequestHeadersProvider();
            var countryCodeProvider        = new CdnHeaderCountryCodeProvider(mockRequestHeadersProvider.Object);
            var criteria   = new CountryPersonalisationGroupCriteria(countryCodeProvider);
            var definition = "{ \"match\": \"CouldNotBeLocated\", \"codes\": [] }";

            // Act
            var result = criteria.MatchesVisitor(definition);

            // Assert
            Assert.IsFalse(result);
        }
Ejemplo n.º 4
0
        public void CountryPersonalisationGroupCriteria_UsingCloudFlareCdnHeaderCountryCodeProvider_MatchesVisitor_WithValidDefinitionWithMatchingCountryListAndNotInCheck_ReturnsFalse()
        {
            // Arrange
            var mockRequestHeadersProvider = MockRequestHeadersProvider();
            var countryCodeProvider        = new CdnHeaderCountryCodeProvider(mockRequestHeadersProvider.Object);
            var criteria   = new CountryPersonalisationGroupCriteria(countryCodeProvider);
            var definition = string.Format(DefinitionFormat, "IsNotLocatedIn", "GB", "IT");

            // Act
            var result = criteria.MatchesVisitor(definition);

            // Assert
            Assert.IsFalse(result);
        }
        public void CountryPersonalisationGroupCriteria_UsingCloudFlareCdnHeaderCountryCodeProvider_MatchesVisitor_WithValidDefinitionForCouldNotBeLocatedWhenCannotLocateAsEmptyHeader_ReturnsTrue()
        {
            // Arrange
            var config = Options.Create(new PersonalisationGroupsConfig());
            var mockRequestHeadersProvider = MockRequestHeadersProvider(withValue: false);
            var countryCodeProvider        = new CdnHeaderCountryCodeProvider(config, mockRequestHeadersProvider.Object);
            var criteria   = new CountryPersonalisationGroupCriteria(countryCodeProvider);
            var definition = "{ \"match\": \"CouldNotBeLocated\", \"codes\": [] }";

            // Act
            var result = criteria.MatchesVisitor(definition);

            // Assert
            Assert.IsTrue(result);
        }
        public void CountryPersonalisationGroupCriteria_UsingCloudFlareCdnHeaderCountryCodeProvider_MatchesVisitor_WithValidDefinitionWithDifferentCountryListAndNotInCheck_ReturnsTrue()
        {
            // Arrange
            var config = Options.Create(new PersonalisationGroupsConfig());
            var mockRequestHeadersProvider = MockRequestHeadersProvider();
            var countryCodeProvider        = new CdnHeaderCountryCodeProvider(config, mockRequestHeadersProvider.Object);
            var criteria   = new CountryPersonalisationGroupCriteria(countryCodeProvider);
            var definition = string.Format(DefinitionFormat, "IsNotLocatedIn", "ES", "IT");

            // Act
            var result = criteria.MatchesVisitor(definition);

            // Assert
            Assert.IsTrue(result);
        }
        public void CountryPersonalisationGroupCriteria_UsingCloudFlareCdnHeaderCountryCodeProvider_MatchesVisitor_WithValidDefinitionWithEmptyCountryLists_ReturnsFalse()
        {
            // Arrange
            var config = Options.Create(new PersonalisationGroupsConfig());
            var mockRequestHeadersProvider = MockRequestHeadersProvider();
            var countryCodeProvider        = new CdnHeaderCountryCodeProvider(config, mockRequestHeadersProvider.Object);
            var criteria   = new CountryPersonalisationGroupCriteria(countryCodeProvider);
            var definition = "{ \"match\": \"IsLocatedIn\", \"codes\": [] }";

            // Act
            var result = criteria.MatchesVisitor(definition);

            // Assert
            Assert.IsFalse(result);
        }