public static IQueryable <T> QueryChildEntitiesByRelationType <T>(this IEntityRepositoryGroup <IProviderTypeFilter> repository, RelationType relationType, HiveId sourceId) where T : TypedEntity, new() { var childIds = repository.GetChildRelations(sourceId, relationType).Select(x => x.DestinationId).ToArray(); return(repository.Query <T>().InIds(childIds)); }
/// <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)); }
/// <summary> /// Mocks a store on the provided IHiveManager mock /// </summary> /// <typeparam name="TFilter">The type of the filter.</typeparam> /// <param name="hive">The hive.</param> /// <param name="uri">The URI.</param> /// <param name="readonlyEntitySession">The readonly entity session.</param> /// <param name="readonlySchemaSession">The readonly schema session.</param> /// <param name="entityRepository">The entity session.</param> /// <param name="schemaRepository">The schema session.</param> /// <returns></returns> public static IHiveManager MockStore <TFilter>( this IHiveManager hive, string uri, out IReadonlyEntityRepositoryGroup <TFilter> readonlyEntitySession, out IReadonlySchemaRepositoryGroup <TFilter> readonlySchemaSession, out IEntityRepositoryGroup <TFilter> entityRepository, out ISchemaRepositoryGroup <TFilter> schemaRepository) where TFilter : class, IProviderTypeFilter { //mock hive var hiveReader = Substitute.For <IReadonlyGroupUnit <TFilter> >(); var hiveWriter = Substitute.For <IGroupUnit <TFilter> >(); hiveReader.FrameworkContext.Returns(hive.FrameworkContext); hiveWriter.FrameworkContext.Returns(hive.FrameworkContext); //mock readers readonlyEntitySession = Substitute.For <IReadonlyEntityRepositoryGroup <TFilter> >(); readonlySchemaSession = Substitute.For <IReadonlySchemaRepositoryGroup <TFilter> >(); readonlyEntitySession.Schemas.Returns(readonlySchemaSession); hiveReader.Repositories.Returns(readonlyEntitySession); //mock writers entityRepository = Substitute.For <IEntityRepositoryGroup <TFilter> >(); entityRepository.FrameworkContext.Returns(hive.FrameworkContext); schemaRepository = Substitute.For <ISchemaRepositoryGroup <TFilter> >(); entityRepository.Schemas.Returns(schemaRepository); hiveWriter.Repositories.Returns(entityRepository); RepositoryContext fakeRepositoryContext = FakeHiveCmsManager.CreateFakeRepositoryContext(hive.FrameworkContext); var readonlyGroupUnitFactory = Substitute.For <ReadonlyGroupUnitFactory <TFilter> >(Enumerable.Empty <ReadonlyProviderSetup>(), new Uri(uri), fakeRepositoryContext, hive.FrameworkContext); readonlyGroupUnitFactory.CreateReadonly().Returns(hiveReader); readonlyGroupUnitFactory.CreateReadonly <TFilter>().Returns(hiveReader); var groupUnitFactory = Substitute.For <GroupUnitFactory <TFilter> >(Enumerable.Empty <ProviderSetup>(), new Uri(uri), fakeRepositoryContext, hive.FrameworkContext); groupUnitFactory.Create().Returns(hiveWriter); groupUnitFactory.Create <TFilter>().Returns(hiveWriter); hive.GetReader <TFilter>().Returns(readonlyGroupUnitFactory); hive.GetReader <TFilter>(null).ReturnsForAnyArgs(readonlyGroupUnitFactory); hive.GetWriter <TFilter>().Returns(groupUnitFactory); hive.GetWriter <TFilter>(null).ReturnsForAnyArgs(groupUnitFactory); return(hive); }
public static IEnumerable <IRelationById> GetParentFileRelations(this IEntityRepositoryGroup <IFileStore> unit, IRelatableEntity source) { Mandate.ParameterNotNull(source, "source"); return(unit.GetParentRelations(source.Id, FixedRelationTypes.DefaultRelationType)); }