Used for the publish dialog
상속: ContentControllerExtenderBase
        public void Publish_Single()
        {
            var entity = CreateEntityRevision(new RegexPropertyEditor());

            var controller = new PublishController(GetBackOfficeRequestContext());
            controller.InjectDependencies(new Dictionary<string, string>(), new Dictionary<string, string>(), GetBackOfficeRequestContext(), false);

            var result = controller.PublishForm(new PublishModel
                {
                    Id = entity.Item.Id,
                    IncludeChildren = false,
                    IncludeUnpublishedChildren = false
                }) as CustomJsonResult;


            //Assert

            Assert.IsNotNull(result);
            var json = JObject.Parse(result.OutputJson());
            Assert.AreEqual(true, json["success"].Value<bool>());

            using (var uow = RebelApplicationContext.Hive.OpenReader<IContentStore>())
            {
                var publishedEntity = uow.Repositories.Revisions.GetLatestRevision<TypedEntity>(entity.Item.Id);
                Assert.AreEqual(FixedStatusTypes.Published.Alias, publishedEntity.MetaData.StatusType.Alias);
            }
        }
        public void Publish_All_Children_That_Are_Not_Already_Published()
        {
            var entity = CreateEntityRevision(new RegexPropertyEditor());
            var subEntity1 = CreateEntityRevision(new RegexPropertyEditor());
            var subEntity2 = CreateEntityRevision(new RegexPropertyEditor());

            using (var writer = RebelApplicationContext.Hive.OpenWriter<IContentStore>())
            {
                var subRev1 = subEntity1.CopyToNewRevision();
                subRev1.Item.RelationProxies.EnlistParent(entity.Item, FixedRelationTypes.DefaultRelationType);
                var subRev2 = subEntity2.CopyToNewRevision();
                subRev2.Item.RelationProxies.EnlistParent(entity.Item, FixedRelationTypes.DefaultRelationType);
                writer.Repositories.Revisions.AddOrUpdate(subRev1);
                writer.Repositories.Revisions.AddOrUpdate(subRev2);
                writer.Complete();
            }

            var controller = new PublishController(GetBackOfficeRequestContext());
            controller.InjectDependencies(new Dictionary<string, string>(), new Dictionary<string, string>(), GetBackOfficeRequestContext(), false);

            var result = controller.PublishForm(new PublishModel
            {
                Id = entity.Item.Id,
                IncludeChildren = true,
                IncludeUnpublishedChildren = true
            }) as CustomJsonResult;


            //Assert

            Assert.IsNotNull(result);
            var json = JObject.Parse(result.OutputJson());
            Assert.AreEqual(true, json["success"].Value<bool>());

            using (var uow = RebelApplicationContext.Hive.OpenReader<IContentStore>())
            {
                var publishedEntity = uow.Repositories.Revisions.GetLatestRevision<TypedEntity>(entity.Item.Id);
                Assert.AreEqual(FixedStatusTypes.Published.Alias, publishedEntity.MetaData.StatusType.Alias);
                
                var publishedSubEntity1 = uow.Repositories.Revisions.GetLatestRevision<TypedEntity>(subEntity1.Item.Id);
                Assert.AreEqual(FixedStatusTypes.Published.Alias, publishedSubEntity1.MetaData.StatusType.Alias);
                
                var publishedSubEntity2 = uow.Repositories.Revisions.GetLatestRevision<TypedEntity>(subEntity2.Item.Id);
                Assert.AreEqual(FixedStatusTypes.Published.Alias, publishedSubEntity2.MetaData.StatusType.Alias);
            }
        }
        public void ContentEditorControllerTest_Actions_Secured_By_Permissions()
        {
            //Arrange
            var backOfficeRequestContext = GetBackOfficeRequestContext();
            var controller = new ContentEditorController(backOfficeRequestContext);
            controller.InjectDependencies(GetBackOfficeRequestContext());

            //TODO: There may be a better way of automatically getting a single controller variable using the controller extenders,
            //but likely that's just testing the action invoker, so for now here's the individual controllers

            var copyController = new MoveCopyController(backOfficeRequestContext);
            copyController.InjectDependencies(GetBackOfficeRequestContext());

            var sortController = new SortController(backOfficeRequestContext);
            sortController.InjectDependencies(GetBackOfficeRequestContext());

            var publishController = new PublishController(backOfficeRequestContext);
            publishController.InjectDependencies(GetBackOfficeRequestContext());

            var hos = new HostnameController(backOfficeRequestContext);
            hos.InjectDependencies(GetBackOfficeRequestContext());

            var rollback = new RollbackController(backOfficeRequestContext);
            rollback.InjectDependencies(GetBackOfficeRequestContext());

            var permissions = new PermissionsController(backOfficeRequestContext);
            permissions.InjectDependencies(GetBackOfficeRequestContext());

            //Assert
            Assert.IsTrue(ActionIsSecuredByPermission(controller, "CreateNew", FixedPermissionIds.Create));
            Assert.IsTrue(ActionIsSecuredByPermission(controller, "Edit", FixedPermissionIds.Update));
            Assert.IsTrue(ActionIsSecuredByPermission(controller, "Delete", FixedPermissionIds.Delete));
            Assert.IsTrue(ActionIsSecuredByPermission(copyController, "Copy", FixedPermissionIds.Copy));
            Assert.IsTrue(ActionIsSecuredByPermission(copyController, "Move", FixedPermissionIds.Move));
            Assert.IsTrue(ActionIsSecuredByPermission(sortController, "Sort", FixedPermissionIds.Sort));
            Assert.IsTrue(ActionIsSecuredByPermission(publishController, "Publish", FixedPermissionIds.Publish));
            Assert.IsTrue(ActionIsSecuredByPermission(permissions, "Permissions", FixedPermissionIds.Permissions));
            Assert.IsTrue(ActionIsSecuredByPermission(rollback, "Rollback", FixedPermissionIds.Rollback));

            // TODO: (APN @ Matt) the assertion for action name doesn't take into account two methods with the same name
            // but differing parameter counts, so this one fails
            // NOTE: (MPB) Have renamed post action to HostnameForm to get test passing for now, not sure if that is enough
            // or whether assertion method should allow you to query for a specific method signature?
            Assert.IsTrue(ActionIsSecuredByPermission(hos, "Hostname", FixedPermissionIds.Hostnames));
        }