Esempio n. 1
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));
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public void Publishes_Many_Does_Not_Ignore_Unpublished_Items()
        {
            CreateTestData();

            var strategy = new PublishingStrategy();

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

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

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

            //there will be 4 here but only one "Success" the rest will be "SuccessAlreadyPublished"
            Assert.AreEqual(1, result.Count(x => x.Result.StatusType == PublishStatusType.Success));
            Assert.AreEqual(3, result.Count(x => x.Result.StatusType == PublishStatusType.SuccessAlreadyPublished));
            Assert.IsTrue(result.Single(x => x.Result.StatusType == PublishStatusType.Success).Success);
            Assert.IsTrue(result.Single(x => x.Result.StatusType == PublishStatusType.Success).Result.ContentItem.Published);
        }