コード例 #1
0
        public void Root_Node_Without_Domains_Causes_SingleWarning()
        {
            var domainServiceMock = new Mock <IDomainService>();

            domainServiceMock.Setup(x => x.GetAssignedDomains(It.IsAny <int>(), It.IsAny <bool>()))
            .Returns(Enumerable.Empty <IDomain>());

            Content rootNode = new ContentBuilder()
                               .WithContentType(CreateContentType())
                               .WithId(1060)
                               .AddContentCultureInfosCollection()
                               .AddCultureInfos()
                               .WithCultureIso("da-dk")
                               .Done()
                               .AddCultureInfos()
                               .WithCultureIso("en-us")
                               .Done()
                               .Done()
                               .Build();

            var culturesPublished = new [] { "en-us", "da-dk" };
            var notifications     = new SimpleNotificationModel();

            ContentController contentController = CreateContentController(domainServiceMock.Object);

            contentController.AddDomainWarnings(rootNode, culturesPublished, notifications);
            Assert.AreEqual(1, notifications.Notifications.Count(x => x.NotificationType == NotificationStyle.Warning));
        }
コード例 #2
0
        public void Root_Node_With_Domains_Causes_No_Warning()
        {
            // Setup domain service
            var domainServiceMock = new Mock <IDomainService>();

            domainServiceMock.Setup(x => x.GetAssignedDomains(1060, It.IsAny <bool>()))
            .Returns(new [] { new UmbracoDomain("/", "da-dk"), new UmbracoDomain("/en", "en-us") });

            // Create content, we need to specify and ID in order to be able to configure domain service
            Content rootNode = new ContentBuilder()
                               .WithContentType(CreateContentType())
                               .WithId(1060)
                               .AddContentCultureInfosCollection()
                               .AddCultureInfos()
                               .WithCultureIso("da-dk")
                               .Done()
                               .AddCultureInfos()
                               .WithCultureIso("en-us")
                               .Done()
                               .Done()
                               .Build();

            var culturesPublished = new [] { "en-us", "da-dk" };
            var notifications     = new SimpleNotificationModel();

            ContentController contentController = CreateContentController(domainServiceMock.Object);

            contentController.AddDomainWarnings(rootNode, culturesPublished, notifications);

            Assert.IsEmpty(notifications.Notifications);
        }
コード例 #3
0
        public void One_Warning_Per_Culture_Being_Published()
        {
            var domainServiceMock = new Mock <IDomainService>();

            domainServiceMock.Setup(x => x.GetAssignedDomains(It.IsAny <int>(), It.IsAny <bool>()))
            .Returns(new [] { new UmbracoDomain("/", "da-dk") });


            Content rootNode = new ContentBuilder()
                               .WithContentType(CreateContentType())
                               .WithId(1060)
                               .AddContentCultureInfosCollection()
                               .AddCultureInfos()
                               .WithCultureIso("da-dk")
                               .Done()
                               .AddCultureInfos()
                               .WithCultureIso("en-us")
                               .Done()
                               .Done()
                               .Build();

            var culturesPublished = new [] { "en-us", "da-dk", "nl-bk", "se-sv" };
            var notifications     = new SimpleNotificationModel();

            ContentController contentController = CreateContentController(domainServiceMock.Object);

            contentController.AddDomainWarnings(rootNode, culturesPublished, notifications);
            Assert.AreEqual(3, notifications.Notifications.Count(x => x.NotificationType == NotificationStyle.Warning));
        }
コード例 #4
0
        public void Ancestor_Domains_Counts()
        {
            var rootId   = 1060;
            var level1Id = 1061;
            var level2Id = 1062;
            var level3Id = 1063;

            var domainServiceMock = new Mock <IDomainService>();

            domainServiceMock.Setup(x => x.GetAssignedDomains(rootId, It.IsAny <bool>()))
            .Returns(new[] { new UmbracoDomain("/", "da-dk") });

            domainServiceMock.Setup(x => x.GetAssignedDomains(level1Id, It.IsAny <bool>()))
            .Returns(new[] { new UmbracoDomain("/en", "en-us") });

            domainServiceMock.Setup(x => x.GetAssignedDomains(level2Id, It.IsAny <bool>()))
            .Returns(new[] { new UmbracoDomain("/se", "se-sv"), new UmbracoDomain("/nl", "nl-bk") });

            Content level3Node = new ContentBuilder()
                                 .WithContentType(CreateContentType())
                                 .WithId(level3Id)
                                 .WithPath($"-1,{rootId},{level1Id},{level2Id},{level3Id}")
                                 .AddContentCultureInfosCollection()
                                 .AddCultureInfos()
                                 .WithCultureIso("da-dk")
                                 .Done()
                                 .AddCultureInfos()
                                 .WithCultureIso("en-us")
                                 .Done()
                                 .AddCultureInfos()
                                 .WithCultureIso("se-sv")
                                 .Done()
                                 .AddCultureInfos()
                                 .WithCultureIso("nl-bk")
                                 .Done()
                                 .AddCultureInfos()
                                 .WithCultureIso("de-de")
                                 .Done()
                                 .Done()
                                 .Build();

            var culturesPublished = new [] { "en-us", "da-dk", "nl-bk", "se-sv", "de-de" };

            ContentController contentController = CreateContentController(domainServiceMock.Object);
            var notifications = new SimpleNotificationModel();

            contentController.AddDomainWarnings(level3Node, culturesPublished, notifications);
            // We expect one error because all domains except "de-de" is registered somewhere in the ancestor path
            Assert.AreEqual(1, notifications.Notifications.Count(x => x.NotificationType == NotificationStyle.Warning));
        }
コード例 #5
0
        public void Only_Warns_About_Cultures_Being_Published()
        {
            var domainServiceMock = new Mock <IDomainService>();

            domainServiceMock.Setup(x => x.GetAssignedDomains(It.IsAny <int>(), It.IsAny <bool>()))
            .Returns(new [] { new UmbracoDomain("/", "da-dk") });

            Content rootNode = new ContentBuilder()
                               .WithContentType(CreateContentType())
                               .WithId(1060)
                               .AddContentCultureInfosCollection()
                               .AddCultureInfos()
                               .WithCultureIso("da-dk")
                               .Done()
                               .AddCultureInfos()
                               .WithCultureIso("en-us")
                               .Done()
                               .AddCultureInfos()
                               .WithCultureIso("se-sv")
                               .Done()
                               .AddCultureInfos()
                               .WithCultureIso("de-de")
                               .Done()
                               .Done()
                               .Build();

            var culturesPublished = new [] { "en-us", "se-sv" };
            var notifications     = new SimpleNotificationModel();

            ContentController contentController = CreateContentController(domainServiceMock.Object);

            contentController.AddDomainWarnings(rootNode, culturesPublished, notifications);

            // We only get two errors, one for each culture being published, so no errors from previously published cultures.
            Assert.AreEqual(2, notifications.Notifications.Count(x => x.NotificationType == NotificationStyle.Warning));
        }