예제 #1
0
        public void WidgetController_EditPost_ShouldCallSaveWidgetOnTheWidgetService()
        {
            var textWidget = new TextWidget {LayoutArea = new LayoutArea()};

            _widgetController.Edit(textWidget);

            A.CallTo(() => _widgetService.SaveWidget(textWidget)).MustHaveHappened();
        }
예제 #2
0
        public void WidgetController_EditPost_IfReturnUrlIsSetRedirectToThere()
        {
            var textWidget = new TextWidget();

            ActionResult result = _widgetController.Edit(textWidget, "test-url");

            result.As<RedirectResult>().Url.Should().Be("test-url");
        }
예제 #3
0
        public void WidgetController_EditGet_ShouldReturnThePassedWidget()
        {
            var textWidget = new TextWidget {Site = new Site()};

            ViewResultBase result = _widgetController.Edit_Get(textWidget);

            result.Model.Should().Be(textWidget);
        }
예제 #4
0
        public void WidgetController_EditPost_ShouldByDefaultRedirectToLayoutIndex()
        {
            var textWidget = new TextWidget {LayoutArea = new LayoutArea {Id = 1}};

            ActionResult result = _widgetController.Edit(textWidget);

            result.As<RedirectToRouteResult>().RouteValues["action"].Should().Be("Edit");
            result.As<RedirectToRouteResult>().RouteValues["controller"].Should().Be("LayoutArea");
            result.As<RedirectToRouteResult>().RouteValues["id"].Should().Be(1);
        }
예제 #5
0
        private void SetupEcommerceLayoutWidgets(MediaModel mediaModel, LayoutModel layoutModel)
        {
            var linkedImageLogo = new LinkedImage
            {
                Name = "Logo",
                Link = "/",
                Image = mediaModel.Logo.FileUrl,
                LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.Single(x => x.AreaName == "Header Left"),
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 60
            };
            _widgetService.AddWidget(linkedImageLogo);
            // Search
            var searchBox = new SearchBox
            {
                Name = "Search",
                LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.Single(x => x.AreaName == "Header Middle"),
                Cache = true,
            };
            _widgetService.AddWidget(searchBox);

            // Ecommerce user links
            var userLinks = new EcommerceUserLinks
            {
                Name = "Ecommerce User Links",
                LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.Single(x => x.AreaName == "User Links")
            };
            _widgetService.AddWidget(userLinks);

            //cart widget
            var cartWidget = new CartWidget
            {
                Name = "Cart Widget",
                LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.Single(x => x.AreaName == "Header Right")
            };
            _widgetService.AddWidget(cartWidget);

            //footer links
            var footerLinksWidget = new TextWidget
            {
                LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.Single(x => x.AreaName == "Footer Area 1"),
                Name = "Footer links",
                Text = EcommerceInstallInfo.FooterText1,
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 60
            };
            _widgetService.AddWidget(footerLinksWidget);

            footerLinksWidget = new TextWidget
            {
                LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.Single(x => x.AreaName == "Footer Area 2"),
                Name = "Footer links",
                Text = EcommerceInstallInfo.FooterText2,
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 60
            };
            _widgetService.AddWidget(footerLinksWidget);

            footerLinksWidget = new TextWidget
            {
                LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.Single(x => x.AreaName == "Footer Area 3"),
                Name = "Footer links",
                Text = EcommerceInstallInfo.FooterText3,
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 60
            };
            _widgetService.AddWidget(footerLinksWidget);

            var afterContentCardsTeaser = new TextWidget
            {
                LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.Single(x => x.AreaName == "After Content"),
                Name = "Footer links",
                Text = EcommerceInstallInfo.AfterContentCardsTeaser,
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 60
            };

            _widgetService.AddWidget(afterContentCardsTeaser);

            var page404 = _documentService.GetDocumentByUrl<TextPage>("404");
            var notFoundProducts = new On404SearchWidget
            {
                LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.Single(x => x.AreaName == "After Content"),
                Name = "What about these?",
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 60,
                Webpage = page404
            };
            _widgetService.AddWidget(notFoundProducts);
        }
예제 #6
0
        private void SetupHomeLayoutWidgets(PageModel pageModel, MediaModel mediaModel, LayoutModel layoutModel)
        {
            var layout = layoutModel.HomeLayout;
            var beforeContent = layoutModel.EcommerceLayout.LayoutAreas.FirstOrDefault(x => x.AreaName == "Before Content");
            var teaser1Area = layout.LayoutAreas.FirstOrDefault(x => x.AreaName == "Teaser1");
            var teaser2Area = layout.LayoutAreas.FirstOrDefault(x => x.AreaName == "Teaser2");
            var teaser3Area = layout.LayoutAreas.FirstOrDefault(x => x.AreaName == "Teaser3");
            var teaser4Area = layout.LayoutAreas.FirstOrDefault(x => x.AreaName == "Teaser4");

            var slider = new Slider
            {
                Image = mediaModel.SliderImage1.FileUrl,
                Image1 = mediaModel.SliderImage2.FileUrl,
                LayoutArea = beforeContent,
                Webpage = pageModel.HomePage,
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 1800
            };
            _widgetService.AddWidget(slider);

            var featuredProducts = new FeaturedProducts
            {
                LayoutArea = beforeContent,
                Webpage = pageModel.HomePage,
                ListOfFeaturedProducts = GetFeaturedProducts(),
                Name = "Featured Products",
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 1800
            };
            _widgetService.AddWidget(featuredProducts);

            //nav
            var nav = new MobileFriendlyNavigation.Widgets.MobileFriendlyNavigation
            {
                Name = "Navigation",
                LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.Single(x => x.AreaName == ("Navigation")),
                IncludeChildren = true,
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 60
            };
            _widgetService.AddWidget(nav);

            var featuredCategories = new FeaturedCategories
            {
                LayoutArea = beforeContent,
                Webpage = pageModel.HomePage,
                ListOfFeaturedCategories = GetFeaturedCategories(),
                Name = "Featured Categories",
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 1800
            };
            _widgetService.AddWidget(featuredCategories);

            var teaser1 = new TextWidget()
            {
                LayoutArea = teaser1Area,
                Webpage = pageModel.HomePage,
                Text = string.Format(@"<div class=""padding-bottom-10""><span><img src=""{0}"" /> </span></div><h3><a href=""#"">FREE delivery on orders over &pound;50. </a></h3><p>Orders placed Monday to Friday before 2pm will generally be picked and packed for immediate despatch. Please note that orders placed over the weekend or on public holidays will be processed on the next working day.</p>", mediaModel.DeliveryIcon.FileUrl),
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 1800
                
            };
            _widgetService.AddWidget(teaser1);

            var teaser2 = new TextWidget()
            {
                LayoutArea = teaser2Area,
                Webpage = pageModel.HomePage,
                Text = string.Format(@"<div class=""padding-bottom-10""><span><img src=""{0}"" /> </span></div><h3><a href=""#"">7 day no question returns.</a></h3><p>We offer a 28 Day Money Back Guarantee. If for any reason you are not completely delighted with your purchase you may download a Returns Form and return it within 28 days of receipt for a full refund or exchange.</p>", mediaModel.ReturnIcon.FileUrl),
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 1800
                
            };
            _widgetService.AddWidget(teaser2);

            var teaser3 = new TextWidget()
            {
                LayoutArea = teaser3Area,
                Webpage = pageModel.HomePage,
                Text = string.Format(@"<div class=""padding-bottom-10""><span><img src=""{0}"" /> </span></div><h3><a href=""#"">Store locations.</a></h3><p>Use our store locator to find a store near you as well as information like opening times, addresses, maps and a list of facilities available at every store.</p>", mediaModel.LocationIcon.FileUrl),
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 1800
                
            };
            _widgetService.AddWidget(teaser3);

            var teaser4 = new TextWidget()
            {
                LayoutArea = teaser4Area,
                Webpage = pageModel.HomePage,
                Text = string.Format(@"<div class=""padding-bottom-10""><span><img src=""{0}"" /> </span></div><h3><a href=""#"">Contact us.</a></h3><p>Our customer service team is always willing to answer your proposal concerning Samsung Service. Your message will be promptly handled under the direct supervision of our executive management.</p>", mediaModel.ContactIcon.FileUrl),
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 60
            };
            _widgetService.AddWidget(teaser4);

            GetFormProperties(pageModel.HomePage);
            //home footer form
            var footerLinksWidgetForm = new TextWidget
            {
                LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.Single(x => x.AreaName == "Footer Area 4"),
                Name = "Footer links",
                Text = string.Format("[form-{0}]", pageModel.HomePage.Id),
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 60
            };
            _widgetService.AddWidget(footerLinksWidgetForm);
        }
예제 #7
0
        public void WidgetController_DeletePost_IfReturnUrlIsSetReturnsRedirectResult()
        {
            var textWidget = new TextWidget();

            ActionResult actionResult = _widgetController.Delete(textWidget, "test");
            actionResult.Should().BeOfType<RedirectResult>();
            actionResult.As<RedirectResult>().Url.Should().Be("test");
        }
예제 #8
0
        public void WidgetController_DeletePost_NullReturnUrlRedirectToRouteResult()
        {
            var textWidget = new TextWidget();

            _widgetController.Delete(textWidget, null).Should().BeOfType<RedirectToRouteResult>();
        }
예제 #9
0
        public void WidgetController_DeleteGet_ReturnsPassedObjectAsModel()
        {
            var textWidget = new TextWidget();

            _widgetController.Delete_Get(textWidget).As<PartialViewResult>().Model.Should().Be(textWidget);
        }
예제 #10
0
        public void WidgetController_DeleteGet_ReturnsPartialViewResult()
        {
            var textWidget = new TextWidget();

            _widgetController.Delete_Get(textWidget).Should().BeOfType<PartialViewResult>();
        }
예제 #11
0
        public void WidgetController_DeletePost_ReturnUrlContainsWidgetEditIgnoreReturnUrl()
        {
            var textWidget = new TextWidget {Id = 1, LayoutArea = new LayoutArea {Id = 1}};

            var result = _widgetController.Delete(textWidget, "/widget/edit/1").As<RedirectToRouteResult>();

            result.RouteValues["controller"].Should().Be("LayoutArea");
            result.RouteValues["action"].Should().Be("Edit");
            result.RouteValues["id"].Should().Be(1);
        }
예제 #12
0
        public void WidgetController_DeletePost_NullReturnUrlLayoutAreaIdSetRedirectsToEditLayoutArea()
        {
            var textWidget = new TextWidget {LayoutArea = new LayoutArea {Id = 1}};

            var result = _widgetController.Delete(textWidget, null).As<RedirectToRouteResult>();

            result.RouteValues["controller"].Should().Be("LayoutArea");
            result.RouteValues["action"].Should().Be("Edit");
            result.RouteValues["id"].Should().Be(1);
        }
예제 #13
0
        public void WidgetController_DeletePost_NullReturnUrlWebpageSetRedirectsToEditWebpage()
        {
            var textWidget = new TextWidget {Webpage = new TextPage {Id = 1}};

            var result = _widgetController.Delete(textWidget, null).As<RedirectToRouteResult>();

            result.RouteValues["controller"].Should().Be("Webpage");
            result.RouteValues["action"].Should().Be("Edit");
            result.RouteValues["id"].Should().Be(1);
        }