private ErrorPages GetErrorPages() { var error403 = new TextPage { Name = "403", UrlSegment = "403", BodyContent = "<h1>403</h1><p>Sorry, you are not authorized to view this page.</p>", RevealInNavigation = false, }; var error404 = new TextPage { Name = "404", UrlSegment = "404", BodyContent = "<h1>404</h1><p>Sorry, this page cannot be found.</p>", RevealInNavigation = false, }; var error500 = new TextPage { Name = "500", UrlSegment = "500", BodyContent = "<h1>500</h1><p>Sorry, there has been an error.</p>", RevealInNavigation = false, }; return new ErrorPages { Error403 = error403, Error404 = error404, Error500 = error500 }; }
public void WebpageController_AddPost_ShouldCallSaveDocument() { var webpage = new TextPage {}; A.CallTo(() => _urlValidationService.UrlIsValidForWebpage(null, null)).Returns(true); _webpageController.Add(webpage); A.CallTo(() => _documentService.AddDocument<Webpage>(webpage)).MustHaveHappened(); }
public void WebpageController_SuggestDocumentUrl_ShouldCallGetDocumentUrl() { var textPage = new TextPage(); var suggestParams = new SuggestParams(); _webpageUrlController.Suggest(textPage, suggestParams); A.CallTo(() => _webpageUrlService.Suggest(textPage,suggestParams)).MustHaveHappened(); }
public void WebpageController_AddGet_ShouldSetParentIdOfModelToIdInMethod() { var textPage = new TextPage { Id = 1}; A.CallTo(() => _documentService.GetDocument<Webpage>(1)).Returns(textPage); var actionResult = _webpageController.Add_Get(1) as ViewResult; (actionResult.Model as AddPageModel).ParentId.Should().Be(1); }
public void WebpageController_AddGet_ShouldCallViewData() { var textPage = new TextPage {}; A.CallTo(() => _documentService.GetDocument<Webpage>(1)).Returns(textPage); _webpageController.Add_Get(1); A.CallTo(() => _baseViewDataService.SetAddPageViewData(_webpageController.ViewData, textPage)) .MustHaveHappened(); }
public void WebpageController_SuggestDocumentUrl_ShouldReturnTheResultOfGetDocumentUrl() { var textPage = new TextPage(); var suggestParams = new SuggestParams(); A.CallTo(() => _webpageUrlService.Suggest(textPage, suggestParams)).Returns("test/result"); string url = _webpageUrlController.Suggest(textPage, suggestParams); url.Should().BeEquivalentTo("test/result"); }
public void WebpageController_Sort_ShouldBeAListOfSortItems() { var textPage = new TextPage(); var webpages = new List<Webpage> {new TextPage()}; A.CallTo(() => _documentService.GetDocumentsByParent<Webpage>(textPage)).Returns(webpages); var viewResult = _webpageController.Sort(textPage).As<ViewResult>(); viewResult.Model.Should().BeOfType<List<SortItem>>(); }
public void WebpageController_Unpublish_CallsDocumentServicePublishNow() { var textPage = new TextPage(); _webpageController.Unpublish(textPage); A.CallTo(() => _documentService.Unpublish(textPage)).MustHaveHappened(); }
public void WebpageController_Unpublish_RedirectsToEditForId() { var textPage = new TextPage {Id = 1}; var result = _webpageController.Unpublish(textPage).As<RedirectToRouteResult>(); result.RouteValues["action"].Should().Be("Edit"); result.RouteValues["id"].Should().Be(1); }
private void GetFormProperties(TextPage home) { home = _documentService.GetDocument<TextPage>(home.Id); var name = new TextBox { Name = "Email", LabelText = "Newsletter Signup", Required = true, DisplayOrder = 1, Webpage = home }; _formAdminService.AddFormProperty(name); _documentService.SaveDocument(home); }
public void FormController_Posting_ReturnsTheResultOfTheCallToGetFormPostings() { var textPage = new TextPage(); var postingsModel = new PostingsModel(PagedList<FormPosting>.Empty, 1); A.CallTo(() => _formAdminService.GetFormPostings(textPage, 1, null)).Returns(postingsModel); _formController.Postings(textPage, 1, null).As<PartialViewResult>().Model.Should().Be(postingsModel); }
public void WebpageController_Sort_ShouldCallGetDocumentsByParentId() { var textPage = new TextPage(); _webpageController.Sort(textPage); A.CallTo(() => _documentService.GetDocumentsByParent<Webpage>(textPage)).MustHaveHappened(); }
public void WebpageController_AddPost_ShouldRedirectToEdit() { var webpage = new TextPage {Id = 1}; A.CallTo(() => _urlValidationService.UrlIsValidForWebpage(null, null)).Returns(true); var result = _webpageController.Add(webpage) as RedirectToRouteResult; result.RouteValues["action"].Should().Be("Edit"); result.RouteValues["id"].Should().Be(1); }
public void WebpageController_EditPost_ShouldRedirectToEdit() { A.CallTo(() => _urlValidationService.UrlIsValidForWebpage(null, 1)).Returns(true); var textPage = new TextPage {Id = 1}; ActionResult actionResult = _webpageController.Edit(textPage); actionResult.Should().BeOfType<RedirectToRouteResult>(); actionResult.As<RedirectToRouteResult>().RouteValues["action"].Should().Be("Edit"); actionResult.As<RedirectToRouteResult>().RouteValues["id"].Should().Be(1); }
public void WebpageController_EditPost_ShouldCallSaveDocument() { A.CallTo(() => _urlValidationService.UrlIsValidForWebpage(null, 1)).Returns(true); Webpage textPage = new TextPage {Id = 1}; _webpageController.Edit(textPage); A.CallTo(() => _documentService.SaveDocument(textPage)).MustHaveHappened(); }
public void WebpageController_EditGet_ShouldSetViewData() { var textPage = new TextPage(); _webpageController.Edit_Get(textPage); A.CallTo(() => _baseViewDataService.SetEditPageViewData(_webpageController.ViewData, textPage)) .MustHaveHappened(); }
public void WebpageController_EditGet_ShouldReturnLayoutAsViewModel() { var webpage = new TextPage {Id = 1}; var result = _webpageController.Edit_Get(webpage) as ViewResult; result.Model.Should().Be(webpage); }
private IEnumerable<Webpage> GetBasicPages() { var homePage = new TextPage { Name = "Home", UrlSegment = "home", BodyContent = "<h1>Mr CMS</h1> <p>Welcome to Mr CMS, the only CMS you will need.</p><p> Turn on inline editing above, then click here. Pretty cool huh? </p>", RevealInNavigation = true, }; CurrentRequestData.HomePage = homePage; yield return homePage; yield return new TextPage { Name = "Page 2", UrlSegment = "page-2", BodyContent = "<h1>Another page</h1><p>Just another page!</p>", RevealInNavigation = true, }; //contact us var contactUs = new TextPage { Name = "Contact us", UrlSegment = "contact-us", BodyContent = "<h1>Contact</h1>Contact us at www.mrcms.com (coming soon). <p>Test form</a> [form]", RevealInNavigation = true, }; AddFormToContactUs(contactUs); yield return contactUs; }
public void WebpageController_AddPost_IfIsValidForWebpageIsFalseShouldReturnViewResult() { var webpage = new TextPage {Id = 1}; A.CallTo(() => _urlValidationService.UrlIsValidForWebpage(null, null)).Returns(false); ActionResult result = _webpageController.Add(webpage); result.Should().BeOfType<ViewResult>(); }
public void WebpageController_DeleteGet_ReturnsDocumentPassedAsModel() { var textPage = new TextPage(); _webpageController.Delete_Get(textPage).As<PartialViewResult>().Model.Should().Be(textPage); }
public void FormController_Postings_CallsFormServiceGetFormPostingsWithPassedArguments() { var textPage = new TextPage(); _formController.Postings(textPage, 1, null); A.CallTo(() => _formAdminService.GetFormPostings(textPage, 1, null)).MustHaveHappened(); }
public void WebpageController_Delete_CallsDeleteDocumentOnThePassedObject() { var textPage = new TextPage(); _webpageController.Delete(textPage); A.CallTo(() => _documentService.DeleteDocument<Webpage>(textPage)).MustHaveHappened(); }
public PageModel Setup(MediaModel mediaModel) { var pageModel = new PageModel(); var productSearch = new ProductSearch { Name = "Categories", UrlSegment = "categories", RevealInNavigation = true }; var categoryContainer = new ProductContainer { Name = "Products", UrlSegment = "products", RevealInNavigation = false }; _documentService.AddDocument(productSearch); _documentService.PublishNow(productSearch); _documentService.AddDocument(categoryContainer); _documentService.PublishNow(categoryContainer); pageModel.ProductSearch = productSearch; var now = DateTime.UtcNow; var yourBasket = new Cart { Name = "Your Basket", UrlSegment = "basket", RevealInNavigation = false, PublishOn = now }; _documentService.AddDocument(yourBasket); var enterOrderEmail = new EnterOrderEmail { Name = "Enter Order Email", UrlSegment = "enter-order-email", RevealInNavigation = false, Parent = yourBasket, DisplayOrder = 0, PublishOn = now, }; _documentService.AddDocument(enterOrderEmail); var setPaymentDetails = new PaymentDetails { Name = "Set Payment Details", UrlSegment = "set-payment-details", RevealInNavigation = false, Parent = yourBasket, DisplayOrder = 1, PublishOn = now, }; _documentService.AddDocument(setPaymentDetails); var setDeliveryDetails = new SetShippingDetails { Name = "Set Shipping Details", UrlSegment = "set-shipping-details", RevealInNavigation = false, Parent = yourBasket, DisplayOrder = 2, PublishOn = now, }; _documentService.AddDocument(setDeliveryDetails); var orderPlaced = new OrderPlaced { Name = "Order Placed", UrlSegment = "order-placed", RevealInNavigation = false, Parent = yourBasket, DisplayOrder = 3, PublishOn = now, }; _documentService.AddDocument(orderPlaced); // User Account var userAccount = new SitemapPlaceholder { Name = "User Account", UrlSegment = "user-account", RevealInNavigation = false, PublishOn = now }; _documentService.AddDocument(userAccount); var userAccountInfo = new UserAccountInfo { Name = "Account Details", UrlSegment = "user-account-details", RevealInNavigation = false, PublishOn = now, Parent = userAccount }; _documentService.AddDocument(userAccountInfo); var userAccountPassword = new UserAccountChangePassword { Name = "Change Password", UrlSegment = "user-account-change-password", RevealInNavigation = false, PublishOn = now, Parent = userAccount }; _documentService.AddDocument(userAccountPassword); var userAccountAddresses = new UserAccountAddresses { Name = "Account Addresses", UrlSegment = "user-account-addresses", RevealInNavigation = false, PublishOn = now, Parent = userAccount }; _documentService.AddDocument(userAccountAddresses); var editAddress = new UserAccountEditAddress { Name = "Edit Address", UrlSegment = userAccountAddresses.UrlSegment + "/edit-address", RevealInNavigation = false, PublishOn = now, Parent = userAccountAddresses }; _documentService.AddDocument(editAddress); var userAccountOrders = new UserAccountOrders { Name = "Orders", UrlSegment = "user-account-orders", RevealInNavigation = false, PublishOn = now, Parent = userAccount }; _documentService.AddDocument(userAccountOrders); var userOrder = new UserOrder { Name = "View Order", UrlSegment = "user-account-orders/order", RevealInNavigation = false, PublishOn = now, Parent = userAccountOrders }; _documentService.AddDocument(userOrder); var userAccountReviews = new UserAccountReviews { Name = "Reviews", UrlSegment = "user-account-reviews", RevealInNavigation = false, PublishOn = now, Parent = userAccount }; _documentService.AddDocument(userAccountReviews); var userAccountRewards = new UserAccountRewardPoints { Name = "Reward Points", UrlSegment = "user-account-reward-points", RevealInNavigation = false, PublishOn = now, Parent = userAccount }; _documentService.AddDocument(userAccountRewards); // End User Account //Added to cart var addedToCart = new ProductAddedToCart { Name = "Added to Basket", UrlSegment = "add-to-basket", RevealInNavigation = false, PublishOn = now }; _documentService.AddDocument(addedToCart); pageModel.ProductAddedToCart = addedToCart; var wishlist = new ShowWishlist { Name = "Wishlist", UrlSegment = "wishlist", RevealInNavigation = true, PublishOn = now }; _documentService.AddDocument(wishlist); var newIn = new NewInProducts { Name = "New In", UrlSegment = "new-in", RevealInNavigation = true, PublishOn = now }; _documentService.AddDocument(newIn); var about = new TextPage() { Name = "About us", UrlSegment = "about-us", RevealInNavigation = true, PublishOn = now, BodyContent = EcommerceInstallInfo.AboutUsText }; _documentService.AddDocument(about); //update core pages var homePage = _documentService.GetDocumentByUrl<TextPage>("home"); if (homePage != null) { homePage.BodyContent = EcommerceInstallInfo.HomeCopy; var templates = _pageTemplateAdminService.Search(new PageTemplateSearchQuery()); var homeTemplate = templates.FirstOrDefault(x => x.Name == "Home Page"); if (homeTemplate != null) { homePage.PageTemplate = homeTemplate; } homePage.SubmitButtonText = "Sign up"; _documentService.SaveDocument(homePage); pageModel.HomePage = homePage; } var page2 = _documentService.GetDocumentByUrl<TextPage>("page-2"); if (page2 != null)//demopage in core not needed _documentService.DeleteDocument(page2); var contactus = _documentService.GetDocumentByUrl<TextPage>("contact-us"); if (contactus != null)//demopage in core not needed _documentService.DeleteDocument(contactus); //Added to cart var contactUs = new ContactUs() { Name = "Contact Us", UrlSegment = "contact-us", RevealInNavigation = true, PublishOn = now, Latitude = 55.01021m, Longitude = -1.44998m, Address = EcommerceInstallInfo.Address, PinImage = mediaModel.Logo.FileUrl, BodyContent = "[form]", FormDesign = EcommerceInstallInfo.ContactFormDesign }; _documentService.AddDocument(contactUs); GetFormProperties(contactUs); var brandListing = new BrandListing { Name = "Brands", UrlSegment = "brands", RevealInNavigation = true, PublishOn = now, BodyContent = "" }; _documentService.AddDocument(brandListing); return pageModel; }
public void WebpageController_Unpublish_ReturnsRedirectToRouteResult() { var textPage = new TextPage {Id = 1}; _webpageController.Unpublish(textPage).Should().BeOfType<RedirectToRouteResult>(); }