コード例 #1
0
 private void _deletePageButton_Click_1(object sender, EventArgs e)
 {
     if (ConfirmRemovePageDialog.Confirm())
     {
         _deletePageCommand.Execute();
     }
 }
コード例 #2
0
        public void Sould_Delete_Page_Successfully()
        {
            RunActionInTransaction(session =>
                {
                    const string url = "/test-link/";
                    var uow = new DefaultUnitOfWork(session);
                    var repository = new DefaultRepository(uow);
                    
                    var page = TestDataProvider.CreateNewPageWithTagsContentsOptionsAndAccessRules(session);
                    
                    session.SaveOrUpdate(page);
                    session.Flush();
                    session.Clear();
                    
                    var pageService = new Mock<IPageService>();
                    pageService.Setup(f => f.ValidatePageUrl(It.IsAny<string>(), It.IsAny<Guid?>()));
                    pageService.Setup(f => f.CreatePagePermalink(It.IsAny<string>(), It.IsAny<string>())).Returns(url);

                    var sitemapService = new Mock<ISitemapService>();
                    sitemapService
                        .Setup(service => service.GetNodesByPage(It.IsAny<PageProperties>()))
                        .Returns(() => new List<SitemapNode>());

                    var urlService = new Mock<IUrlService>();
                    urlService.Setup(f => f.FixUrl(It.IsAny<string>())).Returns((string a) => a);

                    var securityService = new Mock<ICmsSecurityConfiguration>();
                    securityService.Setup(f => f.AccessControlEnabled).Returns(false);

                    var configurationService = new Mock<ICmsConfiguration>();
                    configurationService.Setup(f => f.Security).Returns(securityService.Object);

                    var command = new DeletePageCommand(null, sitemapService.Object, urlService.Object, configurationService.Object);
                    command.Repository = repository;
                    command.UnitOfWork = uow;

                    var result = command.Execute(new DeletePageViewModel
                                        {
                                            PageId = page.Id,
                                            UpdateSitemap = false,
                                            RedirectUrl = null,
                                            SecurityWord = "DELETE",
                                            Version = page.Version
                                        });

                    Assert.IsTrue(result);
                    session.Clear();

                    var actual = repository.AsQueryable<PageProperties>().FirstOrDefault(f => f.Id == page.Id && !f.IsDeleted);                    
                    Assert.IsNull(actual);   
                });
        }
コード例 #3
0
        public void Sould_Delete_Page_Successfully()
        {
            RunActionInTransaction(session =>
            {
                const string url = "/test-link/";
                var uow          = new DefaultUnitOfWork(session);
                var repository   = new DefaultRepository(uow);

                var page = TestDataProvider.CreateNewPageWithTagsContentsOptionsAndAccessRules(session);

                session.SaveOrUpdate(page);
                session.Flush();
                session.Clear();

                var pageService = new Mock <IPageService>();
                pageService.Setup(f => f.ValidatePageUrl(It.IsAny <string>(), It.IsAny <Guid?>()));
                pageService.Setup(f => f.CreatePagePermalink(It.IsAny <string>(), It.IsAny <string>())).Returns(url);

                var sitemapService = new Mock <ISitemapService>();
                sitemapService
                .Setup(service => service.GetNodesByPage(It.IsAny <PageProperties>()))
                .Returns(() => new List <SitemapNode>());

                var urlService = new Mock <IUrlService>();
                urlService.Setup(f => f.FixUrl(It.IsAny <string>())).Returns((string a) => a);

                var securityService = new Mock <ICmsSecurityConfiguration>();
                securityService.Setup(f => f.AccessControlEnabled).Returns(false);

                var configurationService = new Mock <ICmsConfiguration>();
                configurationService.Setup(f => f.Security).Returns(securityService.Object);

                var command        = new DeletePageCommand(null, sitemapService.Object, urlService.Object, configurationService.Object);
                command.Repository = repository;
                command.UnitOfWork = uow;

                var result = command.Execute(new DeletePageViewModel
                {
                    PageId        = page.Id,
                    UpdateSitemap = false,
                    RedirectUrl   = null,
                    SecurityWord  = "DELETE",
                    Version       = page.Version
                });

                Assert.IsTrue(result);
                session.Clear();

                var actual = repository.AsQueryable <PageProperties>().FirstOrDefault(f => f.Id == page.Id && !f.IsDeleted);
                Assert.IsNull(actual);
            });
        }