/// <summary> /// Gets all descendant ids of the <paramref name="entity"/> regardless of publish status. /// </summary> /// <param name="entity">The content.</param> /// <returns></returns> public static IEnumerable <HiveId> AllChildIds(this TypedEntity entity, IHiveManager hiveManager) { if (entity == null) { return(Enumerable.Empty <HiveId>()); } return(hiveManager.FrameworkContext.ScopedCache.GetOrCreateTyped <IEnumerable <HiveId> >( "rvme_AllChildIds_" + entity.Id, () => { // Open a reader and pass in the scoped cache which should be per http-request using (var uow = hiveManager.OpenReader <IContentStore>(hiveManager.FrameworkContext.ScopedCache)) { var hiveIds = uow.Repositories.GetChildRelations(entity.Id, FixedRelationTypes.DefaultRelationType).Select(x => x.DestinationId).ToArray(); // Filter the ancestor ids based on anonymous view permissions //using (var secUow = appContext.Hive.OpenReader<ISecurityStore>(appContext.FrameworkContext.ScopedCache)) // hiveIds = hiveIds.FilterAnonymousWithPermissions(appContext.Security, uow, secUow, new ViewPermission().Id).ToArray(); return hiveIds; } })); return(Enumerable.Empty <HiveId>()); }
public ContentRevisionBuilderStep(IHiveManager hiveManager, T content) : base(hiveManager) { Revision = new Revision <TypedEntity>(content); _contentInstance = content as Content; RelateToRoot = false; }
public EnsureCoreDataTask(IFrameworkContext context, IHiveManager coreManager, IEnumerable<Lazy<Permission, PermissionMetadata>> permissions, ISecurityService securityService) : base(context, coreManager) { _permissions = permissions; _securityService = securityService; }
public static IQueryable <T> QueryAll <T>(IHiveManager hiveManager) { using (var uow = hiveManager.OpenReader <IContentStore>()) { return(uow.Repositories.Select(x => hiveManager.FrameworkContext.TypeMappers.Map <T>(x))); } }
public static T Parent <T>(IHiveManager hiveManager, ISecurityService security, HiveId childId) where T : TypedEntity { // Open a reader and pass in the scoped cache which should be per http-request using (var uow = hiveManager.OpenReader <IContentStore>(hiveManager.FrameworkContext.ScopedCache)) { // TODO: Add path of current to this // We get the relations by id here because we only want to load the parent entity, not both halves of the relation // (as of 15h Oct 2011 but this should change once UoW gets its own ScopedCache added to cater for this - APN) var firstParentFound = uow.Repositories.GetParentRelations(childId, FixedRelationTypes.DefaultRelationType) .FirstOrDefault(); if (firstParentFound != null) { var parentId = firstParentFound.SourceId.AsEnumerableOfOne(); // Filter the ancestor ids based on anonymous view permissions using (var secUow = hiveManager.OpenReader <ISecurityStore>(hiveManager.FrameworkContext.ScopedCache)) parentId = parentId.FilterAnonymousWithPermissions(security, uow, secUow, new ViewPermission().Id).ToArray(); if (!parentId.Any()) { return(null); } //var parent = uow.Repositories.Get<T>(parentId); //if (parent != null) // return hiveManager.FrameworkContext.TypeMappers.Map<T>(parent); var revision = uow.Repositories.Revisions.GetLatestRevision <TypedEntity>(parentId.FirstOrDefault(), FixedStatusTypes.Published); return(revision != null?hiveManager.FrameworkContext.TypeMappers.Map <T>(revision.Item) : null); } } return(null); }
public EnsureCoreDataTask(IFrameworkContext context, IHiveManager coreManager, IEnumerable <Lazy <Permission, PermissionMetadata> > permissions, ISecurityService securityService) : base(context, coreManager) { _permissions = permissions; _securityService = securityService; }
public static IGroupUnit <TFilter> OpenWriter <TFilter>(this IHiveManager hiveManager, AbstractScopedCache overrideCacheScope = null) where TFilter : class, IProviderTypeFilter { var factory = hiveManager.GetWriter <TFilter>(); return(factory.Create <TFilter>(overrideCacheScope)); }
public static WriterResult <TFilter> AutoCommitTo <TFilter>(this IHiveManager manager, Action <IGroupUnit <TFilter> > repository) where TFilter : class, IProviderTypeFilter { using (var unit = manager.OpenWriter <TFilter>()) { try { repository.Invoke(unit); unit.Complete(); return(new WriterResult <TFilter>(true, false)); } catch (Exception outerException) { try { unit.Abandon(); return(new WriterResult <TFilter>(false, true, outerException)); } catch (Exception innerException) { return(new WriterResult <TFilter>(false, false, outerException, innerException)); } } } }
public static IGroupUnit <TFilter> OpenWriter <TFilter>(this IHiveManager hiveManager, Uri providerMappingRoot) where TFilter : class, IProviderTypeFilter { var factory = hiveManager.GetWriter <TFilter>(providerMappingRoot); return(factory.Create <TFilter>()); }
public static EntityPath GetPath(this Content content, IHiveManager hiveManager) { // Open a reader and pass in the scoped cache which should be per http-request using (var uow = hiveManager.OpenReader <IContentStore>(hiveManager.FrameworkContext.ScopedCache)) { return(uow.Repositories.GetEntityPath(content.Id, FixedRelationTypes.DefaultRelationType)); } }
/// <summary> /// /// </summary> /// <param name="hive"></param> /// <param name="settings"></param> /// <param name="frameworkContext"></param> public FakeUmbracoApplicationContext(IHiveManager hive, UmbracoSettings settings, IFrameworkContext frameworkContext) : this(hive) { Hive = hive; Settings = settings; FrameworkContext = frameworkContext; }
public static ISchemaBuilderStep <T, TProviderFilter> NewSchema <T, TProviderFilter>( this IHiveManager hiveManager, string alias) where TProviderFilter : class, IProviderTypeFilter where T : EntitySchema, new() { return(new SchemaBuilderStep <T, TProviderFilter>(hiveManager, hiveManager.CreateSchema <T, TProviderFilter>(alias))); }
protected virtual void BaseTearDown() { if (_hiveManager != null) { _hiveManager.Dispose(); _hiveManager = null; } }
public static ISchemaBuilderStep <EntitySchema, TProviderFilter> NewSchema <TProviderFilter>( this IHiveManager hiveManager, string alias, string name = null) where TProviderFilter : class, IProviderTypeFilter { return(hiveManager.NewSchema <EntitySchema, TProviderFilter>(alias, name)); }
public SecurityService(IHiveManager hive, IEnumerable <Lazy <Permission, PermissionMetadata> > permissions) { Mandate.That <NullReferenceException>(hive != null); Mandate.That <NullReferenceException>(permissions != null); _hive = hive; _permissions = permissions; }
public SecurityService(IHiveManager hive, IEnumerable<Lazy<Permission, PermissionMetadata>> permissions) { Mandate.That<NullReferenceException>(hive != null); Mandate.That<NullReferenceException>(permissions != null); _hive = hive; _permissions = permissions; }
/// <summary> /// /// </summary> /// <param name="hive"></param> /// <param name="settings"></param> /// <param name="frameworkContext"></param> public FakeRebelApplicationContext(IHiveManager hive, RebelSettings settings, IFrameworkContext frameworkContext) : this(hive) { Hive = hive; Settings = settings; FrameworkContext = frameworkContext; }
public static IQueryable <TResult> Query <TResult, TProviderFilter>(this IHiveManager hiveManager) where TResult : class, IReferenceByHiveId where TProviderFilter : class, IProviderTypeFilter { using (var uow = hiveManager.OpenReader <TProviderFilter>()) { return(uow.Repositories.Select(x => hiveManager.FrameworkContext.TypeMappers.Map <TResult>(x))); } }
public DevDatasetInstallTask( IFrameworkContext frameworkContext, IPropertyEditorFactory propertyEditorFactory, IHiveManager hiveManager, IAttributeTypeRegistry attributeTypeRegistry) : base(frameworkContext, hiveManager) { _devDataSet = new DevDataset(propertyEditorFactory, frameworkContext, attributeTypeRegistry); }
/// <summary> /// Creates a new IHiveManager and creates substitutes for the IContentStore /// </summary> /// <param name="hive">The hive.</param> /// <param name="readonlyEntityRepositoryGroup">The readonly entity session.</param> /// <param name="readonlySchemaRepositoryGroup">The readonly schema session.</param> /// <param name="entityRepository">The entity session.</param> /// <param name="schemaSession">The schema session.</param> /// <returns></returns> public static IHiveManager MockContentStore( this IHiveManager hive, out IReadonlyEntityRepositoryGroup <IContentStore> readonlyEntityRepositoryGroup, out IReadonlySchemaRepositoryGroup <IContentStore> readonlySchemaRepositoryGroup, out IEntityRepositoryGroup <IContentStore> entityRepository, out ISchemaRepositoryGroup <IContentStore> schemaSession) { return(hive.MockStore("content://", out readonlyEntityRepositoryGroup, out readonlySchemaRepositoryGroup, out entityRepository, out schemaSession)); }
/// <summary> /// Creates a new IHiveManager and creates substitutes for the IDictionaryStore /// </summary> /// <param name="hive">The hive.</param> /// <param name="readonlyEntityRepositoryGroup">The readonly entity session.</param> /// <param name="readonlySchemaRepositoryGroup">The readonly schema session.</param> /// <param name="entityRepository">The entity session.</param> /// <param name="schemaRepository">The schema session.</param> /// <returns></returns> public static IHiveManager MockDictionaryStore( this IHiveManager hive, out IReadonlyEntityRepositoryGroup <IDictionaryStore> readonlyEntityRepositoryGroup, out IReadonlySchemaRepositoryGroup <IDictionaryStore> readonlySchemaRepositoryGroup, out IEntityRepositoryGroup <IDictionaryStore> entityRepository, out ISchemaRepositoryGroup <IDictionaryStore> schemaRepository) { return(hive.MockStore("dictionary://", out readonlyEntityRepositoryGroup, out readonlySchemaRepositoryGroup, out entityRepository, out schemaRepository)); }
public void Setup() { // Setup languages _languages = new List<LanguageElement> { new LanguageElement { IsoCode = "en-GB", Name = "English (United Kingdom)", Fallbacks = new FallbackCollection { new FallbackElement { IsoCode = "en-US" } } }, new LanguageElement { IsoCode = "en-US", Name = "English (United States)", Fallbacks = new FallbackCollection() } }; // Setup hive var context = new FakeFrameworkContext(); //_hiveManager = FakeHiveCmsManager.NewWithNhibernate(new[] { CreateFakeDictionaryMappingGroup(context) }, context); _hiveManager = new HiveManager(CreateFakeDictionaryMappingGroup(context), context); var root = new TypedEntity { Id = FixedHiveIds.DictionaryVirtualRoot, EntitySchema = FixedSchemas.DictionaryRootSchema, UtcCreated = DateTime.Now, UtcModified = DateTime.Now, UtcStatusChanged = DateTime.Now }; var item1 = CreateDictionatyItem("test1", new Dictionary<string, string> { { "en-GB", "Hello GB" }, { "en-US", "Hello US" } }); var item2 = CreateDictionatyItem("test2", new Dictionary<string, string> { { "en-GB", "World GB" }, { "en-US", "World US" } }); var item3 = CreateDictionatyItem("test3", new Dictionary<string, string> { { "en-GB", "Something GB" }, { "en-US", "Something US" } }); // Act var writer = _hiveManager.GetWriter<IDictionaryStore>(); using (var uow = writer.Create<IDictionaryStore>()) { // Add entities uow.Repositories.AddOrUpdate(root); uow.Repositories.Revisions.AddOrUpdate(item1); uow.Repositories.Revisions.AddOrUpdate(item2); uow.Repositories.Revisions.AddOrUpdate(item3); // Add all relations uow.Repositories.AddRelation(FixedHiveIds.DictionaryVirtualRoot, item1.Item.Id, FixedRelationTypes.DefaultRelationType, 0); uow.Repositories.AddRelation(FixedHiveIds.DictionaryVirtualRoot, item2.Item.Id, FixedRelationTypes.DefaultRelationType, 0); uow.Repositories.AddRelation(item2.Item.Id, item3.Item.Id, FixedRelationTypes.DefaultRelationType, 0); uow.Complete(); } }
public DevDatasetInstallTask( IFrameworkContext frameworkContext, IPropertyEditorFactory propertyEditorFactory, IHiveManager hiveManager, IAttributeTypeRegistry attributeTypeRegistry) : base(frameworkContext, hiveManager) { _devDataSet = new DevDataset(propertyEditorFactory, frameworkContext, attributeTypeRegistry); }
public DynamicContentEnumerator(IEnumerator <TypedEntity> innerEnumerator, IHiveManager hiveManager, IMembershipService <Member> membershipService, IPublicAccessService publicAccessService, object defaultValueIfNull) : base(innerEnumerator) { _membershipService = membershipService; _publicAccessService = publicAccessService; _defaultValueIfNull = defaultValueIfNull; HiveManager = hiveManager; }
protected static dynamic BendIfPossible(TypedEntity entity, IHiveManager hiveManager, object defaultValueIfNull) { var asContent = MapIfPossible(entity, hiveManager.FrameworkContext.TypeMappers); if (asContent == null) { return(defaultValueIfNull); } return(asContent.Bend(hiveManager)); }
public PermissionsService(IHiveManager hive, IEnumerable <Lazy <Permission, PermissionMetadata> > permissions, IMembershipService <User> usersMembershipService) { Mandate.That <NullReferenceException>(hive != null); Mandate.That <NullReferenceException>(permissions != null); _hive = hive; _permissions = permissions; _users = usersMembershipService; }
public PublicAccessService(IHiveManager hive, IMembershipService<Member> membersMembershipService, IFrameworkContext framework) { Mandate.That<NullReferenceException>(hive != null); Mandate.That<NullReferenceException>(membersMembershipService != null); _hive = hive; _members = membersMembershipService; _framework = framework; }
public PublicAccessService(IHiveManager hive, IMembershipService <Member> membersMembershipService, IFrameworkContext framework) { Mandate.That <NullReferenceException>(hive != null); Mandate.That <NullReferenceException>(membersMembershipService != null); _hive = hive; _members = membersMembershipService; _framework = framework; }
public static IQueryable <Content> Children(this Content content, IHiveManager hiveManager) { var childIds = content.AllChildIds(); // Not exactly sure why we need to do it this way, but when done the other way, it doesn't trigger the content type mapper // and therfore looses it's sort order return(hiveManager.Query <TypedEntity, IContentStore>().OfRevisionType(FixedStatusTypes.Published).InIds(childIds) .ToList().Select(x => hiveManager.FrameworkContext.TypeMappers.Map <Content>(x)).AsQueryable()); //return hiveManager.QueryContent().OfRevisionType(FixedStatusTypes.Published).InIds(childIds); }
public PermissionsService(IHiveManager hive, IEnumerable<Lazy<Permission, PermissionMetadata>> permissions, IMembershipService<User> usersMembershipService) { Mandate.That<NullReferenceException>(hive != null); Mandate.That<NullReferenceException>(permissions != null); _hive = hive; _permissions = permissions; _users = usersMembershipService; }
protected static dynamic BendIfPossible(TypedEntity entity, IHiveManager hiveManager, IMembershipService <Member> membershipService, IPublicAccessService publicAccessService, object defaultValueIfNull) { var asContent = MapIfPossible(entity, hiveManager.FrameworkContext.TypeMappers); if (asContent == null) { return(defaultValueIfNull); } return(asContent.Bend(hiveManager, membershipService, publicAccessService)); }
public static T AssertSchemaPartExists <T, TProviderFilter>(IHiveManager hiveManager, HiveId id) where TProviderFilter : class, IProviderTypeFilter where T : AbstractSchemaPart { using (var uow = hiveManager.OpenReader <TProviderFilter>()) { var item = uow.Repositories.Schemas.Get <T>(id); Assert.NotNull(item); return(item); } }
public static ReadonlyGroupUnitFactory <TFilter> TryGetReader <TFilter>(this IHiveManager manager, Uri providerGroupRoot) where TFilter : class, IProviderTypeFilter { var group = manager.TryGetFirstGroup(providerGroupRoot); if (group == null) { return(null); } return(new ReadonlyGroupUnitFactory <TFilter>(group.Group.Readers, group.UriMatch.Root, manager.Context, manager.FrameworkContext)); }
public static IEnumerable <ProviderGroupMatchResult> GetGroups(this IHiveManager manager, Uri providerGroupRoot) { return(manager.ProviderGroups .Select(x => { var isMatch = x.IsMatchForUri(providerGroupRoot); return isMatch.Success ? new ProviderGroupMatchResult(isMatch.MatchingUri, x) : null; }) .WhereNotNull() .AsEnumerable()); }
public static T CreateSchema <T, TProviderFilter>( this IHiveManager hiveManager, string alias) where T : EntitySchema, new() where TProviderFilter : class, IProviderTypeFilter { var schema = new T { Alias = alias }; return(schema); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public MapResolverContext( IFrameworkContext frameworkContext, IHiveManager hive, IPropertyEditorFactory propertyEditorFactory, IParameterEditorFactory parameterEditorFactory) { ApplicationId = Guid.NewGuid(); FrameworkContext = frameworkContext; Hive = hive; PropertyEditorFactory = propertyEditorFactory; ParameterEditorFactory = parameterEditorFactory; }
protected void SetupFakeEnvironment() { // TODO: Prettify and extract smaller methods NhibernateTestSetup = new NhibernateTestSetupHelper(); var storageProvider = new IoHiveTestSetupHelper(NhibernateTestSetup.FakeFrameworkContext); Hive = new HiveManager( new[] { new ProviderMappingGroup( "test", new WildcardUriMatch("content://"), NhibernateTestSetup.ReadonlyProviderSetup, NhibernateTestSetup.ProviderSetup, NhibernateTestSetup.FakeFrameworkContext), storageProvider.CreateGroup("uploader", "storage://file-uploader"), }, NhibernateTestSetup.FakeFrameworkContext); AppContext = new FakeUmbracoApplicationContext(Hive, false); var resolverContext = new MockedMapResolverContext(NhibernateTestSetup.FakeFrameworkContext, Hive, new MockedPropertyEditorFactory(AppContext), new MockedParameterEditorFactory()); var webmModelMapper = new CmsModelMapper(resolverContext); var renderModelMapper = new RenderTypesModelMapper(resolverContext); NhibernateTestSetup.FakeFrameworkContext.SetTypeMappers( new FakeTypeMapperCollection(new AbstractMappingEngine[] { webmModelMapper, renderModelMapper, new FrameworkModelMapper(NhibernateTestSetup.FakeFrameworkContext) })); var membersMembershipProvider = new MembersMembershipProvider { AppContext = AppContext }; membersMembershipProvider.Initialize("MembersMembershipProvider", new NameValueCollection()); MembershipService = new MembershipService<Member, MemberProfile>(AppContext.FrameworkContext, Hive, "security://member-profiles", "security://member-groups", Umbraco.Framework.Security.Model.FixedHiveIds. MemberProfileVirtualRoot, membersMembershipProvider, Enumerable.Empty<MembershipProviderElement>()); PublicAccessService = new PublicAccessService(Hive, MembershipService, AppContext.FrameworkContext); }
public void BeforeTest() { _nhibernateTestSetup = new NhibernateTestSetupHelper(useNhProf:true); var storageProvider = new IoHiveTestSetupHelper(_nhibernateTestSetup.FakeFrameworkContext); Hive = new HiveManager( new[] { new ProviderMappingGroup( "test1", new WildcardUriMatch("content://"), _nhibernateTestSetup.ReadonlyProviderSetup, _nhibernateTestSetup.ProviderSetup, _nhibernateTestSetup.FakeFrameworkContext), new ProviderMappingGroup( "test2", new WildcardUriMatch("security://members"), _nhibernateTestSetup.ReadonlyProviderSetup, _nhibernateTestSetup.ProviderSetup, _nhibernateTestSetup.FakeFrameworkContext), storageProvider.CreateGroup("uploader", "storage://") }, _nhibernateTestSetup.FakeFrameworkContext); var appContext = new FakeRebelApplicationContext(Hive, true); AttributeTypeRegistry.SetCurrent(new CmsAttributeTypeRegistry()); var task = new EnsureCoreDataTask(Hive.FrameworkContext, Hive, Enumerable.Empty<Lazy<Permission, PermissionMetadata>>(), null); task.InstallOrUpgrade(); Provider = new MembersMembershipProvider(Hive, appContext); Provider.Initialize("MembersMembershipProvider", new NameValueCollection()); }
public void Setup() { _nhibernateTestSetup = new NhibernateTestSetupHelper(); var storageProvider = new IoHiveTestSetupHelper(_nhibernateTestSetup.FakeFrameworkContext); Hive = new HiveManager( new[] { new ProviderMappingGroup( "test", new WildcardUriMatch("content://"), _nhibernateTestSetup.ReadonlyProviderSetup, _nhibernateTestSetup.ProviderSetup, _nhibernateTestSetup.FakeFrameworkContext), storageProvider.CreateGroup("uploader", "storage://file-uploader"), }, _nhibernateTestSetup.FakeFrameworkContext); var appContext = new FakeRebelApplicationContext(Hive, false); var resolverContext = new MockedMapResolverContext(_nhibernateTestSetup.FakeFrameworkContext, Hive, new MockedPropertyEditorFactory(appContext), new MockedParameterEditorFactory()); var webmModelMapper = new CmsModelMapper(resolverContext); var renderModelMapper = new RenderTypesModelMapper(resolverContext); _nhibernateTestSetup.FakeFrameworkContext.SetTypeMappers(new FakeTypeMapperCollection(new AbstractMappingEngine[] { webmModelMapper, renderModelMapper, new FrameworkModelMapper(_nhibernateTestSetup.FakeFrameworkContext) })); var membersMembershipProvider = new MembersMembershipProvider { AppContext = appContext }; membersMembershipProvider.Initialize("MembersMembershipProvider", new NameValueCollection()); MembershipService = new MembershipService<Member, MemberProfile>(appContext.FrameworkContext, Hive, "security://member-profiles", "security://member-groups", Framework.Security.Model.FixedHiveIds.MemberProfileVirtualRoot, membersMembershipProvider, Enumerable.Empty<MembershipProviderElement>()); PublicAccessService = new PublicAccessService(Hive, MembershipService, appContext.FrameworkContext); var serializer = new ServiceStackSerialiser(); SerializationService = new SerializationService(serializer); }
public MembersMembershipProvider(IHiveManager hiveManager, IUmbracoApplicationContext appContext) { base.HiveManager = hiveManager; this.AppContext = appContext; }
public void SetUp() { _nhibernateTestSetup = new NhibernateTestSetupHelper(); var storageProvider = new IoHiveTestSetupHelper(_nhibernateTestSetup.FakeFrameworkContext); Hive = new HiveManager( new[] { new ProviderMappingGroup( "test", new WildcardUriMatch("content://"), _nhibernateTestSetup.ReadonlyProviderSetup, _nhibernateTestSetup.ProviderSetup, _nhibernateTestSetup.FakeFrameworkContext), storageProvider.CreateGroup("uploader", "storage://") }, _nhibernateTestSetup.FakeFrameworkContext); // Setup Schemas Hive.Cms() .UsingStore<IContentStore>() .NewSchema("textpageSchema") .Define(NodeNameAttributeDefinition.AliasValue, NodeNameAttributeType.AliasValue, "tab1") .Define(SelectedTemplateAttributeDefinition.AliasValue, SelectedTemplateAttributeType.AliasValue, "tab1") .Commit(); // Setup Content var root = Hive.Cms().NewRevision("Root", "root", "textpageSchema") .SetSelectedTemplate(new HiveId("storage", "templates", new HiveIdValue("/textpageTemplate.cshtml"))) .Publish() .Commit(); // Avoid type scanning in a unit test runner by passing in the known assembly under test var dynamicExtensionAssemblies = typeof (RenderViewModelExtensions).Assembly.AsEnumerableOfOne(); _root = new Content(root.Item).Bend(Hive, null, null, dynamicExtensionAssemblies); var children = new List<dynamic>(); for (var i = 0; i < 10; i++) { // Create child var child = Hive.Cms().NewRevision("Child" + i, "child-" + i, "textpageSchema") .SetSelectedTemplate(new HiveId("storage", "templates", new HiveIdValue("/textpageTemplate.cshtml"))) .SetParent(root.Item) .Publish() .Commit(); children.Add(new Content(child.Item).Bend(Hive, null, null, dynamicExtensionAssemblies)); } _children = children; // Setup dependency resolver var dependencyResolver = Substitute.For<IDependencyResolver>(); dependencyResolver.GetService(typeof(IHiveManager)).Returns(Hive); DependencyResolver.SetResolver(dependencyResolver); }
protected HiveProviderInstallTask(IFrameworkContext context, IHiveManager coreManager) : base(context) { _coreManager = coreManager; }
public DictionaryHelper(IHiveManager hive, IEnumerable<LanguageElement> installedLanguages) { _hiveManager = hive; _installedLanguages = installedLanguages; }
/// <summary> /// TEMPORARY method to install all data required for dev data set excluding all of the core data /// </summary> /// <param name="manager"></param> /// <param name="framework"></param> internal void InstallDevDataset(IHiveManager manager, IFrameworkContext framework) { //LogHelper.Error<PugpigInstallTask>( // string.Format("Inside the dataset class"), new Exception()); //a list of all the schemas we've added var schemas = new List<EntitySchema>(); using (var writer = manager.OpenWriter<IContentStore>()) { //create all of the document type's and their associated tabs first //foreach (var d in _devDataSet.ContentData.Select(x => x.DocumentType).DistinctBy(x => x.Id)) foreach (var d in DocTypes) { var schema = new EntitySchema(d.Alias, d.Name); schema.Id = d.Id; schema.AttributeGroups.AddRange( framework.TypeMappers.Map<IEnumerable<Tab>, IEnumerable<AttributeGroup>>( d.DefinedTabs)); writer.Repositories.Schemas.AddOrUpdate(schema); schemas.Add(schema); foreach (var parentId in d.InheritFrom.Where(x => x.Selected).Select(x => HiveId.Parse(x.Value))) writer.Repositories.AddRelation(new Relation(FixedRelationTypes.DefaultRelationType, parentId, d.Id)); } writer.Complete(); } using (var writer = manager.OpenWriter<IContentStore>()) { //now we can hopefully just map the schema and re-save it so it maps all properties //foreach (var d in _devDataSet.ContentData.Select(x => x.DocumentType).DistinctBy(x => x.Id)) IEnumerable<TypedEntity> typedEntities = writer.Repositories.GetAll<TypedEntity>(); foreach (var d in DocTypes) { var schema = framework.TypeMappers.Map<DocumentTypeEditorModel, EntitySchema>(d); writer.Repositories.Schemas.AddOrUpdate(schema); } writer.Complete(); } using (var writer = manager.OpenWriter<IContentStore>()) { //now just map the entire content entities and persist them, since the attribution definitions and attribution //groups are created these should just map up to the entities in the database. var mappedCollection = framework .TypeMappers.Map<IEnumerable<ContentEditorModel>, IEnumerable<Revision<TypedEntity>>>(ContentData) .ToArray(); mappedCollection.ForEach(x => x.MetaData.StatusType = FixedStatusTypes.Published); //var allAttribTypes = AllAttribTypes(mappedCollection); writer.Repositories.Revisions.AddOrUpdate(mappedCollection); writer.Complete(); } ////now that the data is in there, we need to setup some structure... probably a nicer way to do this but whatevs... its just for testing //using (var writer = mappingGroup.CreateReadWriteUnitOfWork()) //{ // var homeSchema = writer.ReadWriteRepository.GetEntity<EntitySchema>(HiveId.ConvertIntToGuid(1045)); // var contentSchema = writer.ReadWriteRepository.GetEntity<EntitySchema>(HiveId.ConvertIntToGuid(1045)); // var faqContainerSchema = writer.ReadWriteRepository.GetEntity<EntitySchema>(HiveId.ConvertIntToGuid(1055)); // var faqCatSchema = writer.ReadWriteRepository.GetEntity<EntitySchema>(HiveId.ConvertIntToGuid(1056)); // var faqSchema = writer.ReadWriteRepository.GetEntity<EntitySchema>(HiveId.ConvertIntToGuid(1057)); //} }
protected HiveProviderInstallTask(IFrameworkContext context, IHiveManager coreManager);
private void SetupContentTest(IHiveManager hive) { AttributeTypeRegistry.SetCurrent(new CmsAttributeTypeRegistry()); // Ensure parent schema and content root exists for this test var contentVirtualRoot = FixedEntities.ContentVirtualRoot; var systemRoot = new SystemRoot(); var contentRootSchema = new ContentRootSchema(); hive.AutoCommitTo<IContentStore>( x => { x.Repositories.AddOrUpdate(systemRoot); x.Repositories.AddOrUpdate(contentVirtualRoot); x.Repositories.Schemas.AddOrUpdate(contentRootSchema); }); }
public EnsureCoreDataTask(IFrameworkContext context, IHiveManager coreManager, IEnumerable<Lazy<Permission, PermissionMetadata>> permissions) : base(context, coreManager) { _permissions = permissions; }
public void Setup() { // Setup Hive _nhibernateTestSetup = new NhibernateTestSetupHelper(useNhProf: true); var storageProvider = new IoHiveTestSetupHelper(_nhibernateTestSetup.FakeFrameworkContext); Hive = new HiveManager( new[] { new ProviderMappingGroup( "test", new WildcardUriMatch("content://"), _nhibernateTestSetup.ReadonlyProviderSetup, _nhibernateTestSetup.ProviderSetup, _nhibernateTestSetup.FakeFrameworkContext), storageProvider.CreateGroup("uploader", "storage://") }, _nhibernateTestSetup.FakeFrameworkContext); // Setup Schemas Hive.Cms() .UsingStore<IContentStore>() .NewSchema("homepageSchema") .Define(NodeNameAttributeDefinition.AliasValue, NodeNameAttributeType.AliasValue, "tab1") .Define(SelectedTemplateAttributeDefinition.AliasValue, SelectedTemplateAttributeType.AliasValue, "tab1") .Define("siteName", "system-string-type", "tab1") .Define("siteDescription", "system-string-type", "tab1") .Define("bodyText", "system-long-string-type", "tab2") .Commit(); Hive.Cms() .UsingStore<IContentStore>() .NewSchema("textpageSchema") .Define(NodeNameAttributeDefinition.AliasValue, NodeNameAttributeType.AliasValue, "tab1") .Define(SelectedTemplateAttributeDefinition.AliasValue, SelectedTemplateAttributeType.AliasValue, "tab1") .Define("bodyText", "system-long-string-type", "tab1") .Commit(); Hive.Cms() .UsingStore<IContentStore>() .NewSchema("complexpageSchema") .Define(NodeNameAttributeDefinition.AliasValue, NodeNameAttributeType.AliasValue, "tab1") .Define(SelectedTemplateAttributeDefinition.AliasValue, SelectedTemplateAttributeType.AliasValue, "tab1") .Define("color", "system-string-type", "tab1") .Define("integer", "system-integer-type", "tab1") .Define("date", "system-date-time-type", "tab1") .Define("bodyText", "system-long-string-type", "tab1") .Commit(); // Setup Content with a specific DateTime _fixedDate = DateTime.Now.Subtract(TimeSpan.FromMinutes(5)); _homePage = Hive.Cms().NewRevision("Home", "home", "homepageSchema") .SetSelectedTemplate(new HiveId("storage", "templates", new HiveIdValue("/homepageTemplate.cshtml"))) .SetValue("siteName", "Test Site Name") .SetValue("siteDescription", "Test Site Description") .SetValue("bodyText", "<p>Test Site Body Text</p>") .Publish(); _homePage.Revision.Item.UtcCreated = _fixedDate; _homePage.Revision.MetaData.UtcStatusChanged = _fixedDate; _homePage.Commit(); for (var i = 0; i < 5; i++) { // Create child var child = Hive.Cms().NewRevision("Child" + i, "child-" + i, "textpageSchema") .SetSelectedTemplate(new HiveId("storage", "templates", new HiveIdValue("/textpageTemplate.cshtml"))) .SetParent(_homePage.Item) .SetValue("bodyText", "<p>Child Content " + i + " Revision 1 " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>") .Publish() .Commit(); // Create revisions //for (var j = 0; j < i; j++) //{ // Hive.Cms().NewRevisionOf(child.Item) // .SetValue("bodyText", "<p>Child Content " + i + " Revision " + (j + 2) + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>") // .Publish() // .Commit(); //} //if (i < 3) //{ // for (var j = 0; j < 6; j++) // { // // Create grand child // var grandChild = Hive.Cms().NewRevision("Grand Child" + j, "grand-child-" + j, "textpageSchema") // .SetParent(child.Item) // .SetValue("bodyText", "<p>Grand Child Content " + j + " Revision 1 " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>") // .Publish() // .Commit(); // // Create revisions // for (var k = 0; k < j; k++) // { // Hive.Cms().NewRevisionOf(grandChild.Item) // .SetValue("bodyText", "<p>Grand Child Content " + j + " Revision " + (k + 2) + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>") // .Publish() // .Commit(); // } // if (j < 2) // { // // Create great grand children // for (var k = 0; k < 10; k++) // { // var greatGrandChild = // Hive.Cms().NewRevision("Great Grand Child" + k, "great-grand-child-" + k, // "complexpageSchema") // .SetParent(grandChild.Item) // .SetValue("color", "#0000" + k.ToString() + k.ToString()) // .SetValue("integer", k) // .SetValue("date", DateTimeOffset.Now.AddDays(k)) // .SetValue("bodyText", // "<p>Great Grand Child Content " + k + " Revision 1 " + // Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + // Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + // Guid.NewGuid().ToString() + " the end.</p>") // .Publish() // .Commit(); // // Create revisions // for (var l = 0; l < k; l++) // { // Hive.Cms().NewRevisionOf(greatGrandChild.Item) // .SetValue("bodyText", "<p>Great Grand Child Content " + k + " Revision " + (l + 2) + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>") // .Publish() // .Commit(); // } // if (k >= 8) // { // // Create unpublished revisions // Hive.Cms().NewRevisionOf(greatGrandChild.Item) // .SetValue("bodyText", "<p>Great Grand Child Content " + k + " Unpublished Revision " + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>") // .Commit(); // } // } // } // } //} } //for(var i = 0; i < 2; i++) //{ // var trashChild = Hive.Cms().NewRevision("Trash Child" + i, "trash-child-" + i, "textpageSchema") // .SetParent(FixedHiveIds.ContentRecylceBin) // .SetValue("bodyText", "<p>Trash Child Content " + i + " Revision 1 " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>") // .Publish() // .Commit(); //} }
/// <summary> /// Returns a FakeUmbracoApplicationContext by default with the Root node created /// </summary> /// <param name="hive"></param> /// <returns></returns> protected virtual FakeUmbracoApplicationContext CreateApplicationContext(IHiveManager hive) { return new FakeUmbracoApplicationContext(hive); }
protected virtual void BaseTearDown() { if (_hiveManager != null) { _hiveManager.Dispose(); _hiveManager = null; } }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public MockedMapResolverContext(IFrameworkContext frameworkContext, IHiveManager hive, IPropertyEditorFactory propertyEditorFactory, IParameterEditorFactory parameterEditorFactory) : base(frameworkContext, hive, propertyEditorFactory, parameterEditorFactory) { }
public void Initialize() { //Seup permissions _permissions = new Permission[] { new SavePermission(), new PublishPermission(), new HostnamesPermission(), new CopyPermission(), new MovePermission(), new BackOfficeAccessPermission() } .Select(x => new Lazy<Permission, PermissionMetadata>(() => x, new PermissionMetadata(new Dictionary<string, object> { {"Id", x.Id}, {"Name", x.Name}, {"Type", x.Type} }))); //Setup user groups _userGroups = new List<UserGroup> { new UserGroup { Id = new HiveId("9DB63B97-4C8F-489C-98C7-017DC6AD869A"), Name = "Administrator" }, new UserGroup { Id = new HiveId("F61E4B62-513B-4858-91BF-D873401AD3CA"), Name = "Editor" }, new UserGroup { Id = new HiveId("8B65EF91-D49B-43A3-AFD9-6A47D5341B7D"), Name = "Writter" } }; // Setup user id _userId = new HiveId("857BD0F6-49DC-4378-84C1-6CD8AE14301D"); //Setup content nodes _systemRootNode = new TypedEntity { Id = FixedHiveIds.SystemRoot }; _childContentNode = new TypedEntity { Id = new HiveId("00E55027-402F-41CF-9052-B8D8F3DBCD76") }; //Setup relations var systemRootPermissionRelations = new List<RelationById> { new RelationById( _userGroups.First().Id, _systemRootNode.Id, FixedRelationTypes.PermissionRelationType, 0, new RelationMetaDatum(FixedPermissionIds.BackOfficeAccess, PermissionStatus.Allow.ToString()), new RelationMetaDatum(FixedPermissionIds.Copy, PermissionStatus.Allow.ToString()), new RelationMetaDatum(FixedPermissionIds.Save, PermissionStatus.Allow.ToString()), new RelationMetaDatum(FixedPermissionIds.Publish, PermissionStatus.Deny.ToString()), new RelationMetaDatum(FixedPermissionIds.Hostnames, PermissionStatus.Inherit.ToString()), new RelationMetaDatum(FixedPermissionIds.Move, PermissionStatus.Inherit.ToString()) ), new RelationById( _userGroups.Last().Id, _systemRootNode.Id, FixedRelationTypes.PermissionRelationType, 0, new RelationMetaDatum(FixedPermissionIds.Copy, PermissionStatus.Allow.ToString()), new RelationMetaDatum(FixedPermissionIds.Save, PermissionStatus.Deny.ToString()), new RelationMetaDatum(FixedPermissionIds.Publish, PermissionStatus.Allow.ToString()), new RelationMetaDatum(FixedPermissionIds.Hostnames, PermissionStatus.Allow.ToString()), new RelationMetaDatum(FixedPermissionIds.Move, PermissionStatus.Inherit.ToString()) ) }; var childContentNodePermissionRelations = new List<RelationById> { new RelationById( _userGroups.Skip(1).First().Id, _childContentNode.Id, FixedRelationTypes.PermissionRelationType, 0, new RelationMetaDatum(FixedPermissionIds.BackOfficeAccess, PermissionStatus.Deny.ToString()), // Back office access is not an entity action so this should get ignored new RelationMetaDatum(FixedPermissionIds.Copy, PermissionStatus.Allow.ToString()), new RelationMetaDatum(FixedPermissionIds.Save, PermissionStatus.Deny.ToString()), new RelationMetaDatum(FixedPermissionIds.Publish, PermissionStatus.Allow.ToString()), new RelationMetaDatum(FixedPermissionIds.Hostnames, PermissionStatus.Allow.ToString()), new RelationMetaDatum(FixedPermissionIds.Move, PermissionStatus.Inherit.ToString()) ) }; var childContentNodeAncestorRelations = new List<RelationById> { new RelationById( _systemRootNode.Id, _childContentNode.Id, FixedRelationTypes.DefaultRelationType, 0) }; var userGroupRelations = new List<RelationById> { new RelationById( _userGroups.First().Id, _userId, FixedRelationTypes.UserGroupRelationType, 0), new RelationById( _userGroups.Skip(1).First().Id, _userId, FixedRelationTypes.UserGroupRelationType, 0), new RelationById( _userGroups.Last().Id, _userId, FixedRelationTypes.UserGroupRelationType, 0) }; _membershipService = Substitute.For<IMembershipService<User>>(); _membershipService.GetById(_userId, true).Returns(new User { Id = _userId, Username = "******", Groups = _userGroups.Select(x => x.Id).ToArray() }); //Setup hive _hive = MockHiveManager.GetManager() .MockContentStore(out _readonlyContentStoreSession, out _readonlyContentStoreSchemaSession, out _contentStoreRepository, out _contentStoreSchemaRepository) .MockSecurityStore(out _readonlySecurityStoreSession, out _readonlySecurityStoreSchemaSession, out _securityStoreRepository, out _securityStoreSchemaRepository); //Setup content store _readonlyContentStoreSession.Exists<TypedEntity>(HiveId.Empty).ReturnsForAnyArgs(true); _readonlySecurityStoreSession .Get<UserGroup>(true, Arg.Any<HiveId[]>()) .Returns(MockHiveManager.MockReturnForGet<UserGroup>()); _readonlyContentStoreSession .Get<UserGroup>(true, Arg.Any<HiveId[]>()) .Returns(MockHiveManager.MockReturnForGet<UserGroup>()); _securityStoreRepository .Get<UserGroup>(true, Arg.Any<HiveId[]>()) .Returns(MockHiveManager.MockReturnForGet<UserGroup>()); _contentStoreRepository .Get<UserGroup>(true, Arg.Any<HiveId[]>()) .Returns(MockHiveManager.MockReturnForGet<UserGroup>()); //Setup security store _readonlySecurityStoreSession.GetParentRelations(_systemRootNode.Id, FixedRelationTypes.PermissionRelationType).Returns(systemRootPermissionRelations); _readonlySecurityStoreSession.GetParentRelations(_childContentNode.Id, FixedRelationTypes.PermissionRelationType).Returns(childContentNodePermissionRelations); _readonlySecurityStoreSession.GetAncestorRelations(_childContentNode.Id, FixedRelationTypes.DefaultRelationType).Returns(childContentNodeAncestorRelations); _readonlySecurityStoreSession.GetParentRelations(_userId, FixedRelationTypes.UserGroupRelationType).Returns(userGroupRelations); _readonlySecurityStoreSession.Query<UserGroup>().Returns(x => Enumerable.Repeat(new UserGroup() { Name = "Administrator" }, 1).AsQueryable()); }
private void DoCoreAssertions(IHiveManager hiveManager, int totalSchemaCount, int totalEntityCount, int totalAttributeTypeCount, int mediaSchemaCount, IEnumerable<Lazy<Permission, PermissionMetadata>> permissions) { //Assert using (var uow = hiveManager.OpenReader<IContentStore>()) { Assert.IsTrue(uow.Repositories.Exists<TypedEntity>(FixedHiveIds.SystemRoot)); Assert.IsTrue(uow.Repositories.Exists<TypedEntity>(FixedEntities.ContentVirtualRoot.Id)); Assert.IsTrue(uow.Repositories.Exists<TypedEntity>(FixedEntities.ContentRecycleBin.Id)); Assert.IsTrue(uow.Repositories.Exists<TypedEntity>(FixedEntities.MediaVirtualRoot.Id)); Assert.IsTrue(uow.Repositories.Exists<TypedEntity>(FixedEntities.MediaRecycleBin.Id)); Assert.IsTrue(uow.Repositories.Exists<TypedEntity>(FixedEntities.UserGroupVirtualRoot.Id)); Assert.IsTrue(uow.Repositories.Exists<TypedEntity>(FixedEntities.UserVirtualRoot.Id)); Assert.IsTrue(uow.Repositories.Schemas.Exists<EntitySchema>(FixedSchemas.ContentRootSchema.Id)); Assert.IsTrue(uow.Repositories.Schemas.Exists<EntitySchema>(FixedSchemas.MediaRootSchema.Id)); Assert.IsTrue(uow.Repositories.Schemas.Exists<EntitySchema>(FixedSchemas.User.Id)); Assert.IsTrue(uow.Repositories.Schemas.Exists<EntitySchema>(FixedSchemas.UserGroup.Id)); Assert.IsTrue(uow.Repositories.Schemas.Exists<EntitySchema>(FixedSchemas.MediaFolderSchema.Id)); Assert.IsTrue(uow.Repositories.Schemas.Exists<EntitySchema>(FixedSchemas.MediaImageSchema.Id)); var schemas = uow.Repositories.Schemas.GetAll<EntitySchema>().ToArray(); //ensure that schemas have relations on them var mediaImage = schemas.Where(x => x.Alias == "mediaImage").Single(); Assert.True(mediaImage.RelationProxies.IsConnected); Assert.AreEqual(FixedHiveIds.MediaRootSchema.Value, mediaImage.RelationProxies.Single().Item.SourceId.Value); var mediaSchemas = uow.Repositories.Schemas.GetEntityByRelationType<EntitySchema>(FixedRelationTypes.DefaultRelationType, FixedHiveIds.MediaRootSchema); Assert.AreEqual(mediaSchemaCount, mediaSchemas.Count()); //ensure that the built in attribute types are there and set correctly var attributeTypes = uow.Repositories.Schemas.GetAll<AttributeType>().ToArray(); Assert.IsTrue(attributeTypes.Any(x => x.Alias == StringAttributeType.AliasValue)); Assert.IsTrue(attributeTypes.Any(x => x.Alias == BoolAttributeType.AliasValue)); Assert.IsTrue(attributeTypes.Any(x => x.Alias == DateTimeAttributeType.AliasValue)); Assert.IsTrue(attributeTypes.Any(x => x.Alias == IntegerAttributeType.AliasValue)); Assert.IsTrue(attributeTypes.Any(x => x.Alias == TextAttributeType.AliasValue)); Assert.IsTrue(attributeTypes.Any(x => x.Alias == NodeNameAttributeType.AliasValue)); Assert.IsTrue(attributeTypes.Any(x => x.Alias == SelectedTemplateAttributeType.AliasValue)); // TODO: Add other in built attribute types //now make sure that the render types are set var inbuiltString = attributeTypes.Single(x => x.Alias == StringAttributeType.AliasValue); Assert.AreEqual(CorePluginConstants.TextBoxPropertyEditorId, inbuiltString.RenderTypeProvider); var inbuiltText = attributeTypes.Single(x => x.Alias == TextAttributeType.AliasValue); Assert.AreEqual(CorePluginConstants.TextBoxPropertyEditorId, inbuiltText.RenderTypeProvider); var inbuiltDateTime = attributeTypes.Single(x => x.Alias == DateTimeAttributeType.AliasValue); Assert.AreEqual(CorePluginConstants.DateTimePickerPropertyEditorId, inbuiltDateTime.RenderTypeProvider); var inbuiltBool = attributeTypes.Single(x => x.Alias == BoolAttributeType.AliasValue); Assert.AreEqual(CorePluginConstants.TrueFalsePropertyEditorId, inbuiltBool.RenderTypeProvider); // TODO: Add other in built attribute types // Check totals Assert.AreEqual(totalSchemaCount, schemas.Count()); var entities = uow.Repositories.GetAll<TypedEntity>().ToArray(); Assert.AreEqual(totalEntityCount, entities.Count()); //ensure they're all published foreach(var e in entities.Where(x => x.IsContent(uow) || x.IsMedia((uow)))) { var snapshot = uow.Repositories.Revisions.GetLatestSnapshot<TypedEntity>(e.Id); Assert.AreEqual(FixedStatusTypes.Published.Alias, snapshot.Revision.MetaData.StatusType.Alias); } // Admin user is not longer created as part of the data install task //var adminUser = entities.SingleOrDefault(x => x.EntitySchema.Id.Value == FixedHiveIds.UserSchema.Value); //Assert.IsNotNull(adminUser); //Assert.IsTrue(adminUser.AttributeGroups.All(x => x != null)); //Assert.IsTrue(adminUser.AttributeGroups.Any()); //Assert.IsTrue(adminUser.EntitySchema.AttributeGroups.All(x => x != null)); //Assert.IsTrue(adminUser.EntitySchema.AttributeGroups.Any()); //Assert.IsTrue(adminUser.EntitySchema.AttributeDefinitions.Select(x => x.AttributeGroup).All(x => x != null)); var distinctTypesByAlias = attributeTypes.DistinctBy(x => x.Alias).ToArray(); var actualCount = attributeTypes.Count(); var distinctCount = distinctTypesByAlias.Count(); var actualCountById = attributeTypes.DistinctBy(x => x.Id).Count(); var allWithAliasAndId = string.Join("\n", attributeTypes.OrderBy(x => x.Alias).Select(x => x.Alias + ": " + x.Id.Value)); Assert.That(actualCount, Is.EqualTo(distinctCount), "Duplicate AttributeTypes were created: {0} distinct by alias, {1} total loaded from provider, {2} distinct by id. All:{3}".InvariantFormat(distinctCount, actualCount, actualCountById, allWithAliasAndId)); Assert.AreEqual(totalAttributeTypeCount, actualCount); //ensure the default templates are set var contentRoot = new Uri("content://"); var homePage = entities.Single(x => x.Id.EqualsIgnoringProviderId(HiveId.ConvertIntToGuid(contentRoot, null, 1048))); var templateRoot = new Uri("storage://templates"); var templateProvider = "templates"; Assert.AreEqual(new HiveId(templateRoot, templateProvider, new HiveIdValue("Homepage.cshtml")).ToString(), homePage.Attributes[SelectedTemplateAttributeDefinition.AliasValue].DynamicValue.ToString()); var installingModules = entities.Single(x => x.Id.EqualsIgnoringProviderId(HiveId.ConvertIntToGuid(contentRoot, null, 1049))); Assert.AreEqual(new HiveId(templateRoot, templateProvider, new HiveIdValue("Textpage.cshtml")).ToString(), installingModules.Attributes[SelectedTemplateAttributeDefinition.AliasValue].DynamicValue.ToString()); var faq = entities.Single(x => x.Id.EqualsIgnoringProviderId(HiveId.ConvertIntToGuid(contentRoot, null, 1059))); Assert.AreEqual(new HiveId(templateRoot, templateProvider, new HiveIdValue("Faq.cshtml")).ToString(), faq.Attributes[SelectedTemplateAttributeDefinition.AliasValue].DynamicValue.ToString()); //ensure the allowed templates are set Assert.AreEqual(1, homePage.EntitySchema.GetXmlPropertyAsList<HiveId>("allowed-templates").Count()); Assert.AreEqual(new HiveId(templateRoot, templateProvider, new HiveIdValue("Homepage.cshtml")).ToString(), homePage.EntitySchema.GetXmlPropertyAsList<HiveId>("allowed-templates").Single().ToString()); Assert.AreEqual(1, installingModules.EntitySchema.GetXmlPropertyAsList<HiveId>("allowed-templates").Count()); Assert.AreEqual(new HiveId(templateRoot, templateProvider, new HiveIdValue("Textpage.cshtml")).ToString(), installingModules.EntitySchema.GetXmlPropertyAsList<HiveId>("allowed-templates").Single().ToString()); Assert.AreEqual(1, faq.EntitySchema.GetXmlPropertyAsList<HiveId>("allowed-templates").Count()); Assert.AreEqual(new HiveId(templateRoot, templateProvider, new HiveIdValue("Faq.cshtml")).ToString(), faq.EntitySchema.GetXmlPropertyAsList<HiveId>("allowed-templates").Single().ToString()); //ensure the allowed children are set var allowedChildrenOfHomepage = homePage.EntitySchema.GetXmlPropertyAsList<HiveId>("allowed-children").ToArray(); Assert.AreEqual(2, allowedChildrenOfHomepage.Count()); // Check installing-modules is an allowed child of homepage Assert.That(allowedChildrenOfHomepage.Select(x => x.Value), Has.Some.EqualTo(installingModules.EntitySchema.Id.Value)); var faqCat = entities.Single(x => x.Id.EqualsIgnoringProviderId(HiveId.ConvertIntToGuid(contentRoot, null, 1060))); Assert.AreEqual(1, faq.EntitySchema.GetXmlPropertyAsList<HiveId>("allowed-children").Count()); Assert.IsTrue(faqCat.EntitySchema.Id.EqualsIgnoringProviderId(faq.EntitySchema.GetXmlPropertyAsList<HiveId>("allowed-children").Single())); var faqQuestion = entities.Single(x => x.Id.EqualsIgnoringProviderId(HiveId.ConvertIntToGuid(contentRoot, null, 1067))); Assert.AreEqual(1, faqCat.EntitySchema.GetXmlPropertyAsList<HiveId>("allowed-children").Count()); Assert.IsTrue(faqQuestion.EntitySchema.Id.EqualsIgnoringProviderId(faqCat.EntitySchema.GetXmlPropertyAsList<HiveId>("allowed-children").Single())); var userGroups = uow.Repositories.GetAll<UserGroup>() .Where(x => x.EntitySchema.Alias == UserGroupSchema.SchemaAlias); Assert.AreEqual(CoreCmsData.RequiredCoreUserGroups(permissions).Count(), userGroups.Count()); var adminUserGroup = userGroups.First(); Assert.AreEqual(1, adminUserGroup.RelationProxies.GetChildRelations(FixedRelationTypes.PermissionRelationType).Count()); Assert.AreEqual(permissions.Count(), adminUserGroup.RelationProxies.GetChildRelations(FixedRelationTypes.PermissionRelationType).Single().Item.MetaData.Count()); } // Check same method coverage on GroupUnit<T> using (var uow = hiveManager.OpenWriter<IContentStore>()) { Assert.IsTrue(uow.Repositories.Exists<TypedEntity>(FixedHiveIds.SystemRoot)); Assert.IsTrue(uow.Repositories.Schemas.Exists<EntitySchema>(FixedSchemas.ContentRootSchema.Id)); var schemas = uow.Repositories.Schemas.GetAll<EntitySchema>().ToArray(); Assert.AreEqual(totalSchemaCount, schemas.Count()); var mediaImage = schemas.Where(x => x.Alias == "mediaImage").Single(); Assert.True(mediaImage.RelationProxies.IsConnected); Assert.AreEqual(FixedHiveIds.MediaRootSchema.Value, mediaImage.RelationProxies.Single().Item.SourceId.Value); var entities = uow.Repositories.GetAll<TypedEntity>().ToArray(); Assert.AreEqual(totalEntityCount, entities.Count()); var attributeTypes = uow.Repositories.Schemas.GetAll<AttributeType>().ToArray(); Assert.AreEqual(totalAttributeTypeCount, attributeTypes.Count()); } }