Example #1
0
        public void ScoreGroups_WithMatchingMultipleGroups_ReturnsScore()
        {
            // Arrange
            var pickedGroups = new List <IPublishedContent>()
            {
                MockPublishedContent(1000,
                                     PersonalisationGroupDefinitionMatch.All,
                                     PersonalisationGroupDefinitionDuration.Page,
                                     new List <PersonalisationGroupDefinitionDetail>
                {
                    TestHelpers.Definitions.MatchingDayOfWeekDefinition(),
                    TestHelpers.Definitions.MatchingTimeOfDayDefinition(),
                }, 50).Object,
                MockPublishedContent(1001,
                                     PersonalisationGroupDefinitionMatch.Any,
                                     PersonalisationGroupDefinitionDuration.Page,
                                     new List <PersonalisationGroupDefinitionDetail>
                {
                    TestHelpers.Definitions.NonMatchingDayOfWeekDefinition(),
                    TestHelpers.Definitions.MatchingDayOfWeekDefinition(),
                }, 40).Object,
            };

            PersonalisationGroupsConfig.Setup(new PersonalisationGroupsConfig());

            // Act
            var result = UmbracoExtensionsHelper.ScoreGroups(pickedGroups);

            // Assert
            Assert.AreEqual(90, result);
        }
Example #2
0
        public void MatchGroupsByName_WithNameMatchingMatchingGroups_ReturnsTrue()
        {
            // Arrange
            var groups       = new string[] { "Group 1000", "Group 1001" };
            var pickedGroups = new List <IPublishedContent>()
            {
                MockPublishedContent(1000,
                                     PersonalisationGroupDefinitionMatch.All,
                                     PersonalisationGroupDefinitionDuration.Page,
                                     new List <PersonalisationGroupDefinitionDetail>
                {
                    TestHelpers.Definitions.MatchingDayOfWeekDefinition(),
                }).Object,
                MockPublishedContent(1001,
                                     PersonalisationGroupDefinitionMatch.Any,
                                     PersonalisationGroupDefinitionDuration.Page,
                                     new List <PersonalisationGroupDefinitionDetail>
                {
                    TestHelpers.Definitions.MatchingTimeOfDayDefinition(),
                }).Object,
            };

            PersonalisationGroupsConfig.Setup(new PersonalisationGroupsConfig());

            // Act
            var result = UmbracoExtensionsHelper.MatchGroupsByName(groups, pickedGroups, PersonalisationGroupDefinitionMatch.All);

            // Assert
            Assert.IsTrue(result);
        }
 public GroupMatchingService(
     IOptions <PersonalisationGroupsConfig> config,
     ICriteriaService criteriaService,
     IStickyMatchService stickyMatchService,
     IPublishedValueFallback publishedValueFallback)
 {
     _config                 = config.Value;
     _criteriaService        = criteriaService;
     _stickyMatchService     = stickyMatchService;
     _publishedValueFallback = publishedValueFallback;
 }
Example #4
0
        public void MatchGroups_WithNoGroups_ReturnsFalse()
        {
            // Arrange
            var pickedGroups = new List <IPublishedContent>();

            PersonalisationGroupsConfig.Setup(new PersonalisationGroupsConfig());

            // Act
            var result = UmbracoExtensionsHelper.MatchGroups(pickedGroups);

            // Assert
            Assert.IsFalse(result);
        }
Example #5
0
        public void ScoreGroups_WithPackageDisabled_ReturnsDefaultScore()
        {
            // Arrange
            var pickedGroups = new List <IPublishedContent>();

            PersonalisationGroupsConfig.Setup(new PersonalisationGroupsConfig(disablePackage: true));

            // Act
            var result = UmbracoExtensionsHelper.ScoreGroups(pickedGroups);

            // Assert
            Assert.AreEqual(0, result);
        }
Example #6
0
        public void MatchGroups_WithPackageDisabled_ReturnsTrue()
        {
            // Arrange
            var pickedGroups = new List <IPublishedContent>();

            PersonalisationGroupsConfig.Setup(new PersonalisationGroupsConfig(disablePackage: true));

            // Act
            var result = UmbracoExtensionsHelper.MatchGroups(pickedGroups);

            // Assert
            Assert.IsTrue(result);
        }
Example #7
0
        public void MatchGroupsByName_WithPackageDisabledUsingAny_ReturnsTrue()
        {
            // Arrange
            var groups       = new string[] { "Group 1000", "Group X" };
            var pickedGroups = new List <IPublishedContent>();

            PersonalisationGroupsConfig.Setup(new PersonalisationGroupsConfig(disablePackage: true));

            // Act
            var result = UmbracoExtensionsHelper.MatchGroupsByName(groups, pickedGroups, PersonalisationGroupDefinitionMatch.Any);

            // Assert
            Assert.IsTrue(result);
        }
Example #8
0
        public void MatchGroups_WithNoMatchingGroupsUsingAny_ReturnsFalse()
        {
            // Arrange
            var pickedGroups = new List <IPublishedContent>()
            {
                MockPublishedContent(1000,
                                     PersonalisationGroupDefinitionMatch.Any,
                                     PersonalisationGroupDefinitionDuration.Page,
                                     new List <PersonalisationGroupDefinitionDetail>
                {
                    TestHelpers.Definitions.NonMatchingDayOfWeekDefinition(),
                    TestHelpers.Definitions.NonMatchingDayOfWeekDefinition()
                }).Object,
            };

            PersonalisationGroupsConfig.Setup(new PersonalisationGroupsConfig());

            // Act
            var result = UmbracoExtensionsHelper.MatchGroups(pickedGroups);

            // Assert
            Assert.IsFalse(result);
        }
Example #9
0
 public GeoLocationController(IOptions <PersonalisationGroupsConfig> config, IHostingEnvironment hostingEnvironment, AppCaches appCaches)
 {
     _config             = config.Value;
     _hostingEnvironment = hostingEnvironment;
     _appCaches          = appCaches;
 }
 public StickyMatchService(IOptions <PersonalisationGroupsConfig> config, ICookieProvider cookieProvider, IDateTimeProvider dateTimeProvider)
 {
     _config           = config.Value;
     _cookieProvider   = cookieProvider;
     _dateTimeProvider = dateTimeProvider;
 }
 public void Setup()
 {
     // Ensure that Config.Setup is OK in each test
     PersonalisationGroupsConfig.Reset();
 }
 public CdnHeaderCountryCodeProvider(IOptions <PersonalisationGroupsConfig> config, IRequestHeadersProvider requestHeadersProvider)
 {
     _config = config.Value;
     _requestHeadersProvider = requestHeadersProvider;
 }
 public UserActivityTracker(IOptions <PersonalisationGroupsConfig> config, ICookieProvider cookieProvider, IDateTimeProvider dateTimeProvider)
 {
     _config           = config.Value;
     _cookieProvider   = cookieProvider;
     _dateTimeProvider = dateTimeProvider;
 }
Example #14
0
 public CookiePagesViewedProvider(IOptions <PersonalisationGroupsConfig> config, ICookieProvider cookieProvider)
 {
     _config         = config.Value;
     _cookieProvider = cookieProvider;
 }
Example #15
0
 public CookieNumberOfVisitsProvider(IOptions <PersonalisationGroupsConfig> config, ICookieProvider cookieProvider)
 {
     _config         = config.Value;
     _cookieProvider = cookieProvider;
 }
Example #16
0
 public CriteriaService(IOptions <PersonalisationGroupsConfig> config, IServiceProvider serviceProvider, AppCaches appCaches)
 {
     _config          = config.Value;
     _serviceProvider = serviceProvider;
     _appCaches       = appCaches;
 }
Example #17
0
 public HttpContextIpProvider(IOptions <PersonalisationGroupsConfig> config, IHttpContextAccessor httpContextAccessor, ClientIpParser clientIpParser)
 {
     _config = config.Value;
     _httpContextAccessor = httpContextAccessor;
     _clientIpParser      = clientIpParser;
 }
Example #18
0
 public HttpContextCookieProvider(IOptions <PersonalisationGroupsConfig> config, IHttpContextAccessor httpContextAccessor, ISessionManager sessionManager)
 {
     _config = config.Value;
     _httpContextAccessor = httpContextAccessor;
     _sessionManager      = sessionManager;
 }