protected override void Initialize() { base.Initialize(); _httpContextFactory = new FakeHttpContextFactory("~/Home"); var umbracoSettings = Factory.GetInstance <IUmbracoSettingsSection>(); var globalSettings = Factory.GetInstance <IGlobalSettings>(); var umbracoContextAccessor = Factory.GetInstance <IUmbracoContextAccessor>(); _xml = new XmlDocument(); _xml.LoadXml(GetXml()); var xmlStore = new XmlStore(() => _xml, null, null, null); var appCache = new DictionaryAppCache(); var domainCache = new DomainCache(ServiceContext.DomainService, DefaultCultureAccessor); var publishedShapshot = new PublishedSnapshot( new PublishedContentCache(xmlStore, domainCache, appCache, globalSettings, new SiteDomainHelper(), umbracoContextAccessor, ContentTypesCache, null, null), new PublishedMediaCache(xmlStore, ServiceContext.MediaService, ServiceContext.UserService, appCache, ContentTypesCache, Factory.GetInstance <IEntityXmlSerializer>(), umbracoContextAccessor), new PublishedMemberCache(null, appCache, Current.Services.MemberService, ContentTypesCache, umbracoContextAccessor), domainCache); var publishedSnapshotService = new Mock <IPublishedSnapshotService>(); publishedSnapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny <string>())).Returns(publishedShapshot); _umbracoContext = new UmbracoContext( _httpContextFactory.HttpContext, publishedSnapshotService.Object, new WebSecurity(_httpContextFactory.HttpContext, Current.Services.UserService, globalSettings), umbracoSettings, Enumerable.Empty <IUrlProvider>(), globalSettings, new TestVariationContextAccessor()); _cache = _umbracoContext.ContentCache; }
public ForcedPreviewObject(PublishedSnapshot publishedShapshot, bool preview, Action <bool>?callback) { _publishedSnapshot = publishedShapshot; _callback = callback; // save and force _origPreview = publishedShapshot._defaultPreview; publishedShapshot._defaultPreview = preview; }
protected override void Initialize() { base.Initialize(); _httpContextFactory = new FakeHttpContextFactory("~/Home"); var globalSettings = new GlobalSettings(); var umbracoContextAccessor = Factory.GetRequiredService <IUmbracoContextAccessor>(); _xml = new XmlDocument(); _xml.LoadXml(GetXml()); var xmlStore = new XmlStore(() => _xml, null, null, null, HostingEnvironment); var appCache = new DictionaryAppCache(); var domainCache = new DomainCache(Mock.Of <IDomainService>(), DefaultCultureAccessor); var publishedShapshot = new PublishedSnapshot( new PublishedContentCache(xmlStore, domainCache, appCache, globalSettings, ContentTypesCache, null, VariationContextAccessor, null), new PublishedMediaCache(xmlStore, Mock.Of <IMediaService>(), Mock.Of <IUserService>(), appCache, ContentTypesCache, Factory.GetRequiredService <IEntityXmlSerializer>(), umbracoContextAccessor, VariationContextAccessor), new PublishedMemberCache(ContentTypesCache, VariationContextAccessor), domainCache); var publishedSnapshotService = new Mock <IPublishedSnapshotService>(); publishedSnapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny <string>())).Returns(publishedShapshot); var httpContext = _httpContextFactory.HttpContext; var httpContextAccessor = TestHelper.GetHttpContextAccessor(httpContext); _umbracoContext = new UmbracoContext( httpContextAccessor, publishedSnapshotService.Object, Mock.Of <IBackOfficeSecurity>(), globalSettings, HostingEnvironment, new TestVariationContextAccessor(), UriUtility, new AspNetCookieManager(httpContextAccessor)); _cache = _umbracoContext.Content; }