Ejemplo n.º 1
0
        public void ExpandVisitorGroupReference_WhenReferenceIsNotFound_ShouldNotSetVisitorGroups()
        {
            // Arrange
            var subject = new ContentMap();
            var function = new ComposerContentFunction { VisitorGroupContainerID = Guid.NewGuid() };

            // Act
            subject.ExpandVisitorGroupReference(function);

            // Assert
            Assert.IsFalse(function.VisitorGroups.Any());
        }
Ejemplo n.º 2
0
        public void ExpandVisitorGroupReference_WhenReferenceHasBeenRegistered_ShouldSetVisitorGroups()
        {
            // Arrange
            var subject = new ContentMap();
            var reference = Guid.NewGuid();
            var visitorGroups = new[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
            var function = new ComposerContentFunction { VisitorGroupContainerID = reference };
            subject.AddVisitorGroupMap(reference, visitorGroups);

            // Act
            subject.ExpandVisitorGroupReference(function);

            // Assert
            Assert.AreEqual(3, function.VisitorGroups.Count());
            Assert.IsTrue(function.VisitorGroups.SequenceEqual(visitorGroups));
        }
Ejemplo n.º 3
0
        public virtual void RestructurePersonalizationContainer(ComposerContentFunction container, ComposerContentArea parentArea)
        {
            var parentFunctions = parentArea.ContentFunctions;
            var insertIndex = parentFunctions.IndexOf(container);
            parentFunctions.RemoveAt(insertIndex);

            // TODO: This assumption should be validated sometime before this call!
            // Composer Personalization Containers should only have one single ContentArea
            var functions = container.ContentAreas.Single().ContentFunctions;
            var personalizationGroup = CreatePersonalizationGroupName();
            foreach (var f in functions)
            {
                f.PersonalizationGroup = personalizationGroup;
                ExpandVisitorGroupReference(f);
                parentFunctions.Insert(insertIndex++, f);
            }
        }
Ejemplo n.º 4
0
        public virtual void ExpandVisitorGroupReference(ComposerContentFunction function)
        {
            if (function.VisitorGroupContainerID == Guid.Empty)
                return;

            function.VisitorGroups = GetVisitorGroups(function.VisitorGroupContainerID).Where(x => x != Guid.Empty).ToArray();
        }
Ejemplo n.º 5
0
        private static ComposerPage CreatePersonalizedComposerPage(Guid containerGuid, IEnumerable<ComposerContentFunction> functions)
        {
            var personalizedContainer = new ComposerContentFunction
            {
                Guid = containerGuid,
                Language = DefaultLanguage,
                ContentAreas = {
                    new ComposerContentArea {
                        Name = "PersonalizationArea",
                        ContentFunctions = functions.ToList()
                    }
                }
            };

            return new ComposerPage
            {
                Guid = Guid.NewGuid(),
                Language = DefaultLanguage,
                ContentAreas = {
                    new ComposerContentArea {
                        Name = DefaultAreaName,
                        ContentFunctions = { personalizedContainer }
                    }
                }
            };
        }
Ejemplo n.º 6
0
        public void GetParent_WhenGuidMatchPage_ShouldReturnNull()
        {
            // Arrange
            var subject = new ContentMap();
            var function = new ComposerContentFunction { Guid = Guid.NewGuid(), Language = DefaultLanguage };
            var page = new ComposerPage
            {
                Guid = Guid.NewGuid(),
                Language = DefaultLanguage,
                ContentAreas = { new ComposerContentArea { Name = DefaultAreaName, ContentFunctions = { function } } }
            };
            subject.AddPage(page);

            // Act
            var result = subject.GetParentPage(page.Guid);

            // Assert
            Assert.IsNull(result);
        }
Ejemplo n.º 7
0
        public void GetParent_WhenGuidMatchesFunction_ShouldReturnPage()
        {
            // Arrange
            var subject = new ContentMap();

            var function = new ComposerContentFunction { Guid = Guid.NewGuid() };
            var page = new ComposerPage
            {
                Name = "Page name",
                Guid = Guid.NewGuid(),
                Language = DefaultLanguage,
                ContentAreas = { new ComposerContentArea { Name = DefaultAreaName, ContentFunctions = { function } } }
            };

            subject.AddPage(page);

            // Act
            var result = subject.GetParentPage(function.Guid);

            // Assert
            Assert.AreSame(page, result);
        }
Ejemplo n.º 8
0
        public void GetContentFunctions_WhenLanguageIsIncorrect_ShouldCheckParentLanguage()
        {
            // Arrange
            var subject = new ContentMap();
            var nestedFunction = new ComposerContentFunction { Guid = Guid.NewGuid(), Language = DefaultLanguage };

            var layoutFunction = new ComposerContentFunction
            {
                Guid = Guid.NewGuid(),
                Language = DefaultLanguage,
                ContentAreas = { new ComposerContentArea { Name = DefaultAreaName, ContentFunctions = { nestedFunction } } }
            };

            var page = new ComposerPage
            {
                Guid = Guid.NewGuid(),
                Language = "sv",
                ContentAreas = { new ComposerContentArea { Name = DefaultAreaName, ContentFunctions = { layoutFunction } } }
            };

            subject.AddPage(page);

            // Act
            var result = subject.GetContentFunctions(layoutFunction.Guid, DefaultLanguage)[DefaultAreaName];

            // Assert
            Assert.AreEqual(1, result.Count());
            Assert.IsTrue(result.Any(b => b.Guid == nestedFunction.Guid));
        }
Ejemplo n.º 9
0
        public void GetContentFunctions_WhenContentHasFunction_ShouldReturnLookupWithAnyFunction()
        {
            // Arrange
            var subject = new ContentMap();
            var function = new ComposerContentFunction { Guid = Guid.NewGuid() };
            var page = new ComposerPage
            {
                Guid = Guid.NewGuid(),
                Language = DefaultLanguage,
                ContentAreas = { new ComposerContentArea { Name = DefaultAreaName, ContentFunctions = { function } } }
            };
            subject.AddPage(page);

            // Act
            var result = subject.GetContentFunctions(page.Guid, page.Language)[DefaultAreaName];

            // Assert
            Assert.AreEqual(1, result.Count());
            Assert.IsTrue(result.Any(b => b.Guid == function.Guid));
        }