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));
        }
        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);
        }
Пример #3
0
        public virtual void ExpandVisitorGroupReference(ComposerContentFunction function)
        {
            if (function.VisitorGroupContainerID == Guid.Empty)
            {
                return;
            }

            function.VisitorGroups = GetVisitorGroups(function.VisitorGroupContainerID).Where(x => x != Guid.Empty).ToArray();
        }
        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());
        }
Пример #5
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);
            }
        }
        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));
        }
        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);
        }