public void EngineApiContentTypeTest()
        {
            var content = _unitTestEngine.WithPublishedContentPage(contentType: _unitTestEngine.WithPublishedContentType());

            var controller = new BasicUmbracoApiController(_unitTestEngine.UmbracoContext, _unitTestEngine.UmbracoHelper);

            _unitTestEngine.RegisterController(controller);
            var res = controller.BasicContentTypeAction(content.Id);

            Assert.AreEqual(content.ContentType.Alias, res);
        }
        public void BasicApiContentTypeTest()
        {
            //create a mock of the content type service
            var mockContentService = new Mock <IContentTypeService>();
            //this time we will make our own service context, which can take in all of the umbraco services
            //Pass the context the mocked content service object
            var serviceContext = new ServiceContext(contentTypeService: mockContentService.Object);

            var appCtx = ApplicationContext.EnsureContext(
                new DatabaseContext(Mock.Of <IDatabaseFactory>(), Mock.Of <ILogger>(), new SqlSyntaxProviders(new[] { Mock.Of <ISqlSyntaxProvider>() })),
                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 alias = "test_alias";

            //we need to mock a content type composition with our alias
            var mockContentType = new Mock <IContentType>();

            mockContentType.Setup(s => s.Alias).Returns(alias);
            //we are not going to give any property types because this will cause an error down the line
            mockContentType.Setup(s => s.CompositionPropertyTypes).Returns(new PropertyType[] { });

            //PublishedContentType.Get will eventually request a content type from one of the data services (content, media, member)
            //In our case content
            //We tell it which content type object to return
            mockContentService.Setup(s => s.GetContentType(alias)).Returns(mockContentType.Object);

            var ContentType = PublishedContentType.Get(PublishedItemType.Content, alias);

            var contentId = 2;
            //get a mocked IPublishedContent
            var contentMock = BasicHelpers.GetPublishedContentMock();

            contentMock.Setup(s => s.ContentType).Returns(ContentType);

            var mockedTypedQuery = new Mock <ITypedPublishedContentQuery>();

            mockedTypedQuery.Setup(s => s.TypedContent(contentId)).Returns(contentMock.Object);

            //give our dynamic query mock to the longer version of the UmbracoHelper constructor
            var helper = new UmbracoHelper(ctx,
                                           Mock.Of <IPublishedContent>(),
                                           mockedTypedQuery.Object,
                                           Mock.Of <IDynamicPublishedContentQuery>(),
                                           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.BasicContentTypeAction(contentId);

            Assert.AreEqual(alias, res);
        }