Exemplo n.º 1
0
        public void Publishes_Many_Does_Not_Ignore_Unpublished_Items()
        {
            CreateTestData();

            IPublishingStrategy2 strategy = new PublishingStrategy(DatabaseContext.ScopeProvider, new TransientMessagesFactory(), Logger);

            //publish root and nodes at it's children level
            var result1 = strategy.Publish(_unitOfWork, _homePage, 0);

            Assert.IsTrue(result1);
            Assert.IsTrue(_homePage.Published);

            //NOTE (MCH) This isn't persisted, so not really a good test as it will look like the result should be something else.
            foreach (var c in ServiceContext.ContentService.GetChildren(_homePage.Id))
            {
                var r = strategy.Publish(_unitOfWork, c, 0);
                Assert.IsTrue(r);
                Assert.IsTrue(c.Published);
            }

            //NOTE (MCH) when doing the test like this the Publish status will not actually have been persisted
            //since its only updating a property. The actual persistence and publishing is done through the ContentService.
            //So when descendants are fetched from the ContentService the Publish status will be "reset", which
            //means the result will be 1 'SuccessAlreadyPublished' and 3 'Success' because the Homepage is
            //inserted in the list and since that item has the status of already being Published it will be the one item
            //with 'SuccessAlreadyPublished'

            var descendants = ServiceContext.ContentService.GetDescendants(_homePage).Concat(new[] { _homePage });
            var result      = strategy.PublishWithChildren(_unitOfWork, descendants, 0, true);

            Assert.AreEqual(3, result.Count(x => x.Result.StatusType == PublishStatusType.Success));
            Assert.AreEqual(1, result.Count(x => x.Result.StatusType == PublishStatusType.SuccessAlreadyPublished));
            Assert.IsTrue(result.First(x => x.Result.StatusType == PublishStatusType.Success).Success);
            Assert.IsTrue(result.First(x => x.Result.StatusType == PublishStatusType.Success).Result.ContentItem.Published);
        }
Exemplo n.º 2
0
        public void Publishes_Many_Ignores_Unpublished_Items()
        {
            CreateTestData();

            IPublishingStrategy2 strategy = new PublishingStrategy(DatabaseContext.ScopeProvider, new TransientMessagesFactory(), Logger);

            //publish root and nodes at it's children level
            var result1 = strategy.Publish(_unitOfWork, _homePage, 0);

            Assert.IsTrue(result1);
            Assert.IsTrue(_homePage.Published);
            foreach (var c in ServiceContext.ContentService.GetChildren(_homePage.Id))
            {
                var r = strategy.Publish(_unitOfWork, c, 0);
                Assert.IsTrue(r);
                Assert.IsTrue(c.Published);
            }

            //ok, all are published except the deepest descendant, we will pass in a flag to not include it to
            //be published
            var result = strategy.PublishWithChildren(_unitOfWork,
                                                      ServiceContext.ContentService.GetDescendants(_homePage).Concat(new[] { _homePage }), 0, false);

            //all of them will be SuccessAlreadyPublished unless the unpublished one gets included, in that case
            //we'll have a 'Success' result which we don't want.
            Assert.AreEqual(0, result.Count(x => x.Result.StatusType == PublishStatusType.Success));
        }
Exemplo n.º 3
0
        public void Publishes_Many_Ignores_Cancelled_Items_And_Children()
        {
            CreateTestData();

            IPublishingStrategy2 strategy = new PublishingStrategy(DatabaseContext.ScopeProvider, new TransientMessagesFactory(), Logger);


            PublishingStrategy.Publishing += PublishingStrategyPublishing;

            //publish root and nodes at it's children level
            var listToPublish = ServiceContext.ContentService.GetDescendants(_homePage.Id).Concat(new[] { _homePage });
            var result        = strategy.PublishWithChildren(_unitOfWork, listToPublish, 0, true);

            Assert.AreEqual(listToPublish.Count() - 2, result.Count(x => x.Success));
            Assert.IsTrue(result.Where(x => x.Success).Select(x => x.Result.ContentItem.Id)
                          .ContainsAll(listToPublish.Where(x => x.Name != "Text Page 2" && x.Name != "Text Page 3").Select(x => x.Id)));
        }
Exemplo n.º 4
0
        public void Publishes_Many_Ignores_Invalid_Items_And_Children()
        {
            var testData = CreateTestData();
            //Create some other data which are descendants of Text Page 2
            var mandatorContent = MockedContent.CreateSimpleContent(
                ServiceContext.ContentTypeService.GetContentType("umbMandatory"), "Invalid Content", testData.Single(x => x.Name == "Text Page 2").Id);

            mandatorContent.SetValue("author", string.Empty);
            ServiceContext.ContentService.Save(mandatorContent, 0);
            var subContent = MockedContent.CreateSimpleContent(
                ServiceContext.ContentTypeService.GetContentType("umbTextpage"), "Sub Sub Sub", mandatorContent.Id);

            ServiceContext.ContentService.Save(subContent, 0);

            IPublishingStrategy2 strategy = new PublishingStrategy(DatabaseContext.ScopeProvider, new TransientMessagesFactory(), Logger);

            //publish root and nodes at it's children level
            var listToPublish = ServiceContext.ContentService.GetDescendants(_homePage.Id).Concat(new[] { _homePage });
            var result        = strategy.PublishWithChildren(_unitOfWork, listToPublish, 0, true);

            Assert.AreEqual(listToPublish.Count() - 2, result.Count(x => x.Success));
            Assert.IsTrue(result.Where(x => x.Success).Select(x => x.Result.ContentItem.Id)
                          .ContainsAll(listToPublish.Where(x => x.Name != "Invalid Content" && x.Name != "Sub Sub Sub").Select(x => x.Id)));
        }