Exemple #1
0
 private PublishedContentRequest NeedsPublishedContentRequest()
 {
     if (_publishedContentRequest == null)
     {
         _publishedContentRequest = UmbracoUnitTestHelper.GetPublishedContentRequest(UmbracoContext, currentContent: _mocks.ResolveObject <IPublishedContent>("Current"));
         UmbracoContext.PublishedContentRequest = _publishedContentRequest;
     }
     return(_publishedContentRequest);
 }
        public void HelperPublishedContent3Test()
        {
            var ctx = UmbracoUnitTestHelper.GetUmbracoContext();

            var mockContent = UmbracoUnitTestHelper.GetPublishedContentMock(name: "test");

            UmbracoUnitTestHelper.SetPublishedContentRequest(ctx, UmbracoUnitTestHelper.GetPublishedContentRequest(ctx, currentContent: mockContent.Object));

            var res   = new BasicTestSurfaceController().BasicPublishedContentAction();
            var model = res.Model as string;

            Assert.AreEqual(mockContent.Object.Name, model);
        }
        public void HelperCurrentPageTest()
        {
            //Setup UmbracoContext with mocks. Sets UmbracoContext.Current
            var ctx = UmbracoUnitTestHelper.GetUmbracoContext();

            var content = new TestPublishedContent()
            {
                Name = "test"
            };

            var controller = new BasicTestSurfaceController();

            //Setting the controller context will provide the route data, route def, publushed content request, and current page to the surface controller
            controller.ControllerContext = UmbracoUnitTestHelper.GetControllerContext(ctx, controller, UmbracoUnitTestHelper.GetPublishedContentRequest(ctx, currentContent: content));

            var res   = controller.BasicCurrentPageAction();
            var model = res.Model as string;

            Assert.AreEqual(content.Name, model);
        }