Example #1
0
        protected Mock<IUmbracoHelperService> SetupRepositoryTypedContent(IPublishedContentRepository repository, int pageId)
        {
            var umbracoHelperService = new Mock<IUmbracoHelperService>();

            umbracoHelperService.Setup(x => x.TypedContent(pageId))
                .Returns(repository.GetNode(pageId));

            return umbracoHelperService;
        }
Example #2
0
        protected INodeService SetupRepositoryNodeService(IPublishedContentRepository repository, IUmbracoHelperService umbracoHelperService)
        {
            var publishedContentExtensionService = new Mock<IPublishedContentExtensionService>();

            IEnumerable<IPublishedContent> children = null;
            publishedContentExtensionService.Setup(x => x.Children(It.IsAny<IPublishedContent>()))
                .Callback((IPublishedContent publishedContent) => children = repository.Children(publishedContent))
                .Returns(() => children.Select(x => x));

            IEnumerable<IPublishedContent> ancestors = null;
            publishedContentExtensionService.Setup(x => x.Ancestors(It.IsAny<IPublishedContent>()))
                .Callback((IPublishedContent publishedContent) => ancestors = repository.Ancestors(publishedContent))
                .Returns(() => ancestors.Select(x => x));

            return new NodeService(new UmbracoMapper(), umbracoHelperService,
                publishedContentExtensionService.Object);
        }