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));
        }
        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_WhenGuidMatchesShadowGuidAndHasFunctions_ShouldReturnPage()
        {
            // Arrange
            var subject = new ContentMap();

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

            subject.AddPage(page);

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

            // Assert
            Assert.AreSame(page, result);
        }
Exemplo n.º 4
0
        public void AddPage_ShouldAddPageToMap()
        {
            // Arrange
            var subject = new ContentMap();
            var page = new ComposerPage { Guid = Guid.NewGuid(), Language = DefaultLanguage };

            // Act
            subject.AddPage(page);

            // Assert
            var result = subject.GetPage(page.Guid, page.Language);
            Assert.AreSame(page, result);
        }
        public void GetContentFunctions_WhenContentDoesntHaveAnyFunctions_ShouldReturnEmptyLookup()
        {
            // Arrange
            var subject      = new ContentMap();
            var composerPage = new ComposerPage {
                Guid = Guid.NewGuid(), Language = DefaultLanguage
            };

            subject.AddPage(composerPage);

            // Act
            var result = subject.GetContentFunctions(composerPage.Guid, composerPage.Language);

            // Assert
            Assert.IsFalse(result.Any());
        }
        public void AddPage_ShouldAddPageToMap()
        {
            // Arrange
            var subject = new ContentMap();
            var page    = new ComposerPage {
                Guid = Guid.NewGuid(), Language = DefaultLanguage
            };

            // Act
            subject.AddPage(page);

            // Assert
            var result = subject.GetPage(page.Guid, page.Language);

            Assert.AreSame(page, result);
        }
        public void RestructurePersonalization_ShouldSetTheSamePersonalizationGroupOnAllFunctions()
        {
            // Arrange
            var subject         = new ContentMap();
            var sourceFunctions = new[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
            var containerGuid   = Guid.NewGuid();
            var page            = CreatePersonalizedComposerPage(containerGuid, sourceFunctions);

            subject.AddPage(page);
            subject.AddPersonalisationContainer(containerGuid);

            // Act
            subject.RestructurePersonalization();

            // Assert
            var restructuredFunctions = subject.GetContentFunctions(page.Guid, DefaultLanguage).Single().ToArray();

            Assert.IsTrue(restructuredFunctions.Skip(1).All(b => b.PersonalizationGroup == restructuredFunctions[0].PersonalizationGroup));
        }
        public void GetParent_WhenShadowGuidOfAddedPageIsEmpty_ShouldReturnNull()
        {
            // Arrange
            var subject = new ContentMap();

            var page = new ComposerPage
            {
                Guid       = Guid.NewGuid(),
                ShadowGuid = Guid.Empty,
                Language   = DefaultLanguage,
            };

            subject.AddPage(page);

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

            // Assert
            Assert.IsNull(result);
        }
        public void GetContentFunctions_WhenContentHasAreaWithoutFunctions_ShouldReturnLookupWithoutFunctions()
        {
            // Arrange
            var subject = new ContentMap();
            var page    = new ComposerPage
            {
                Guid         = Guid.NewGuid(),
                Language     = DefaultLanguage,
                ContentAreas = { new ComposerContentArea {
                                     Name = DefaultAreaName
                                 } }
            };

            subject.AddPage(page);

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

            // Assert
            Assert.IsFalse(result.Any());
        }
Exemplo n.º 10
0
        public void RestructurePersonalization_ShouldMovePersonalizedFunctionsToContainerParent()
        {
            // Arrange
            var subject         = new ContentMap();
            var sourceFunctions = new[] { Guid.NewGuid(), Guid.NewGuid() };
            var containerGuid   = Guid.NewGuid();
            var page            = CreatePersonalizedComposerPage(containerGuid, sourceFunctions);

            subject.AddPage(page);
            subject.AddPersonalisationContainer(containerGuid);

            // Act
            subject.RestructurePersonalization();

            // Assert
            var restructuredFunctions = subject.GetContentFunctions(page.Guid, DefaultLanguage).Single().ToList();

            Assert.AreEqual(2, restructuredFunctions.Count());
            Assert.AreEqual(sourceFunctions[0], restructuredFunctions[0].Guid);
            Assert.AreEqual(sourceFunctions[1], restructuredFunctions[1].Guid);
        }
Exemplo n.º 11
0
        public void GetParent_WhenGuidMatchesShadowGuidButPageHasNoFunctions_ShouldReturnNull()
        {
            // Arrange
            var subject = new ContentMap();

            var page = new ComposerPage
            {
                Name       = "Page name",
                Guid       = Guid.NewGuid(),
                Language   = DefaultLanguage,
                ShadowGuid = Guid.NewGuid()
            };

            subject.AddPage(page);

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

            // Assert
            Assert.IsNull(result);
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        public void GetContentFunctions_WhenContentDoesntHaveAnyFunctions_ShouldReturnEmptyLookup()
        {
            // Arrange
            var subject = new ContentMap();
            var composerPage = new ComposerPage { Guid = Guid.NewGuid(), Language = DefaultLanguage };
            subject.AddPage(composerPage);

            // Act
            var result = subject.GetContentFunctions(composerPage.Guid, composerPage.Language);

            // Assert
            Assert.IsFalse(result.Any());
        }
Exemplo n.º 14
0
        public void GetParent_WhenGuidMatchesShadowGuidAndHasFunctions_ShouldReturnPage()
        {
            // Arrange
            var subject = new ContentMap();

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

            subject.AddPage(page);

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

            // Assert
            Assert.AreSame(page, result);
        }
Exemplo n.º 15
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));
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
0
        public void GetParent_WhenGuidMatchesShadowGuidButPageHasNoFunctions_ShouldReturnNull()
        {
            // Arrange
            var subject = new ContentMap();

            var page = new ComposerPage
            {
                Name = "Page name",
                Guid = Guid.NewGuid(),
                Language = DefaultLanguage,
                ShadowGuid = Guid.NewGuid()
            };

            subject.AddPage(page);

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

            // Assert
            Assert.IsNull(result);
        }
Exemplo n.º 18
0
        public void GetParent_WhenShadowGuidOfAddedPageIsEmpty_ShouldReturnNull()
        {
            // Arrange
            var subject = new ContentMap();

            var page = new ComposerPage
            {
                Guid = Guid.NewGuid(),
                ShadowGuid = Guid.Empty,
                Language = DefaultLanguage,
            };

            subject.AddPage(page);

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

            // Assert
            Assert.IsNull(result);
        }
Exemplo n.º 19
0
        public void RestructurePersonalization_ShouldMovePersonalizedFunctionsToContainerParent()
        {
            // Arrange
            var subject = new ContentMap();
            var sourceFunctions = new[] { Guid.NewGuid(), Guid.NewGuid() };
            var containerGuid = Guid.NewGuid();
            var page = CreatePersonalizedComposerPage(containerGuid, sourceFunctions);
            subject.AddPage(page);
            subject.AddPersonalisationContainer(containerGuid);

            // Act
            subject.RestructurePersonalization();

            // Assert
            var restructuredFunctions = subject.GetContentFunctions(page.Guid, DefaultLanguage).Single().ToList();
            Assert.AreEqual(2, restructuredFunctions.Count());
            Assert.AreEqual(sourceFunctions[0], restructuredFunctions[0].Guid);
            Assert.AreEqual(sourceFunctions[1], restructuredFunctions[1].Guid);
        }
Exemplo n.º 20
0
        public void RestructurePersonalization_ShouldSetTheSamePersonalizationGroupOnAllFunctions()
        {
            // Arrange
            var subject = new ContentMap();
            var sourceFunctions = new[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
            var containerGuid = Guid.NewGuid();
            var page = CreatePersonalizedComposerPage(containerGuid, sourceFunctions);
            subject.AddPage(page);
            subject.AddPersonalisationContainer(containerGuid);

            // Act
            subject.RestructurePersonalization();

            // Assert
            var restructuredFunctions = subject.GetContentFunctions(page.Guid, DefaultLanguage).Single().ToArray();
            Assert.IsTrue(restructuredFunctions.Skip(1).All(b => b.PersonalizationGroup == restructuredFunctions[0].PersonalizationGroup));
        }
Exemplo n.º 21
0
        public void GetContentFunctions_WhenContentAreaDoesNotExist_ShouldReturnLookupWithoutFunctions()
        {
            // Arrange
            var subject = new ContentMap();
            var areaName = "Area54";
            var page = new ComposerPage
            {
                Guid = Guid.NewGuid(),
                Language = DefaultLanguage,
                ContentAreas = { new ComposerContentArea { Name = DefaultAreaName } }
            };
            subject.AddPage(page);

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

            // Assert
            Assert.IsFalse(result.Any());
        }
Exemplo n.º 22
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));
        }