Esempio n. 1
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);
        }
        private static bool MatchesGroups(this UmbracoHelper helper, string[] groupNames, PersonalisationGroupDefinitionMatch matchType)
        {
            var groupsRootFolder = GetGroupsRootFolder(helper);

            if (groupsRootFolder == null)
            {
                return(false);
            }

            var groups = GetGroups(groupsRootFolder);

            return(UmbracoExtensionsHelper.MatchGroupsByName(groupNames, groups, matchType));
        }
Esempio n. 3
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);
        }