public void EngineApiDynamicContentMediaTest()
        {
            //Auto fixture will take care of the name and unit test EngineApi will assign an ID
            var content = _unitTestEngine.WithPublishedContentPage();
            var media   = _unitTestEngine.WithPublishedMedia();

            var controller = new BasicUmbracoApiController(_unitTestEngine.UmbracoContext, _unitTestEngine.UmbracoHelper);
            var res        = controller.BasicDynamicContentMediaAction(content.Id, media.Id);

            Assert.AreEqual(content.Name, res.Item1);
            Assert.AreEqual(media.Name, res.Item2);
        }
        public void BasicApiDynamicContentMediaTest()
        {
            var appCtx = ApplicationContext.EnsureContext(
                new DatabaseContext(Mock.Of <IDatabaseFactory>(), Mock.Of <ILogger>(), new SqlSyntaxProviders(new[] { Mock.Of <ISqlSyntaxProvider>() })),
                new ServiceContext(),
                CacheHelper.CreateDisabledCacheHelper(),
                new ProfilingLogger(
                    Mock.Of <ILogger>(),
                    Mock.Of <IProfiler>()), true);

            var ctx = UmbracoContext.EnsureContext(
                Mock.Of <HttpContextBase>(),
                appCtx,
                new Mock <WebSecurity>(null, null).Object,
                Mock.Of <IUmbracoSettingsSection>(),
                Enumerable.Empty <IUrlProvider>(), true);

            var contentName = "contentName";
            var mediaName   = "mediaName";
            var contentId   = 20;
            var mediaId     = 30;

            //create content items to be returned
            var mediaItem   = BasicHelpers.GetPublishedContentMock(name: mediaName, id: mediaId);
            var contentItem = BasicHelpers.GetPublishedContentMock(name: contentName, id: contentId);

            //we create a mock of the dynamic query, which is used internally by the Umbraco helper
            var mockedDynamicQuery = new Mock <IDynamicPublishedContentQuery>();

            mockedDynamicQuery.Setup(s => s.Content(contentId)).Returns(contentItem.Object);
            mockedDynamicQuery.Setup(s => s.Media(mediaId)).Returns(mediaItem.Object);

            //give our dynamic query mock to the longer version of the UmbracoHelper constructor
            var helper = new UmbracoHelper(ctx,
                                           Mock.Of <IPublishedContent>(),
                                           Mock.Of <ITypedPublishedContentQuery>(),
                                           mockedDynamicQuery.Object,
                                           Mock.Of <ITagQuery>(),
                                           Mock.Of <IDataTypeService>(),
                                           new UrlProvider(ctx, Mock.Of <IWebRoutingSection>(section => section.UrlProviderMode == UrlProviderMode.Auto.ToString()), new[] { Mock.Of <IUrlProvider>() }),
                                           Mock.Of <ICultureDictionary>(),
                                           Mock.Of <IUmbracoComponentRenderer>(),
                                           new MembershipHelper(ctx, Mock.Of <MembershipProvider>(), Mock.Of <RoleProvider>()));

            var controller = new BasicUmbracoApiController(ctx, helper);
            var res        = controller.BasicDynamicContentMediaAction(contentId, mediaId);

            Assert.AreEqual(contentItem.Object.Name, res.Item1);
            Assert.AreEqual(mediaItem.Object.Name, res.Item2);
        }