/// <summary> /// This will take some to build out... /// </summary> public static ServiceContext GetServiceContext(MockServiceContext mockServiceContext = null) { return(mockServiceContext != null ? mockServiceContext.ServiceContext : new ServiceContext()); }
/// <summary> /// To allow Helper.GetPublishedContentType and PublishedContentType.Get to work /// /// https://github.com/umbraco/Umbraco-CMS/blob/67c3ea7c00f44cf3426a37c2cc62e7b561fc859a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs ln 133-170 /// </summary> /// <param name="mockServiceContext"></param> public static void SetupServicesForPublishedContentTypeResolution(MockServiceContext mockServiceContext, IEnumerable <PropertyType> propertyTypes = null) { mockServiceContext.ContentTypeService.Setup(s => s.GetContentType(It.IsAny <string>())).Returns <string>(s => GetContentTypeComposition <IContentType>(alias: s, propertyTypes: propertyTypes)); mockServiceContext.ContentTypeService.Setup(s => s.GetMediaType(It.IsAny <string>())).Returns <string>(s => GetContentTypeComposition <IMediaType>(alias: s, propertyTypes: propertyTypes)); mockServiceContext.MemberTypeService.Setup(s => s.Get(It.IsAny <string>())).Returns <string>(s => GetContentTypeComposition <IMemberType>(alias: s, propertyTypes: propertyTypes)); }