Example #1
0
        public PublishedContentType WithPublishedContentType(int?id = null, string name = null, string alias = null, IEnumerable <PropertyType> propertyTypes = null)
        {
            alias = alias ?? _Fixture.Create <string>();
            id    = id.HasValue ? id : _Fixture.Create <int>(); //use unique ID system?
            name  = name ?? _Fixture.Create <string>();
            PublishedContentType contentType = null;

            if ((contentType = this.ContentTypes.FirstOrDefault(c => c.Alias == alias)) != null) //already existings, return
            {
                return(contentType);
            }
            if (propertyTypes != null && propertyTypes.Count() > 0) //need boot manager for property types...
            {
                NeedsCoreBootManager();
            }
            mockServiceContext.ContentTypeService.Setup(s => s.GetContentType(alias)).Returns(UmbracoUnitTestHelper.GetContentTypeComposition <IContentType>(alias: alias, name: name, id: id, propertyTypes: propertyTypes));
            contentType = UmbracoUnitTestHelper.GetPublishedContentType(PublishedItemType.Content, alias);
            return(contentType);
        }