public IReadOnlyList <IContainer> SubContainersFor(SpeciesPopulation speciesPopulation, IContainer parentContainer) { var pathToParentContainer = _entityPathResolver.PathFor(parentContainer); var flatParentContainer = _flatContainerRepository.ContainerFrom(pathToParentContainer); return(_populationContainerRepository.AllSubContainerFor(speciesPopulation.Name, flatParentContainer.Id).MapAllUsing(_containerMapper)); }
private ICache <int, FlatPopulationContainer> populationSubContainers(SpeciesPopulation population, FlatContainer parentContainer) { var result = new Cache <int, FlatPopulationContainer>(x => x.Id); result.AddRange(_populationContainerRepo.AllSubContainerFor(population.Name, parentContainer.Id)); return(result); }
protected override void Context() { _entityPathResolver = new EntityPathResolver(new ObjectPathFactoryForSpecs()); _flatContainerIdToContainerMapper = A.Fake <IFlatContainerIdToContainerMapper>(); _modelContainerRepo = A.Fake <IFlatModelContainerRepository>(); _compartment = A.Fake <IContainer>(); _populationName = "HUMAN_POP"; A.CallTo(() => _modelContainerRepo.All()).Returns( new List <FlatModelContainer> { NewFMC(1, "C1", "ORGAN", "M1"), NewFMC(2, "C2", "COMPARTMENT", "M1"), NewFMC(3, Constants.ROOT, "SIMULATION", "M1") }); _populationContainerRepo = A.Fake <IFlatPopulationContainerRepository>(); A.CallTo(() => _populationContainerRepo.AllSubContainerFor(_populationName, 3)).Returns( new List <FlatPopulationContainer> { CreateFlatPopulationContainer(1, "C1", "ORGAN", _populationName), }); A.CallTo(() => _populationContainerRepo.AllSubContainerFor(_populationName, 1)).Returns( new List <FlatPopulationContainer> { CreateFlatPopulationContainer(2, "C2", "COMPARTMENT", _populationName) }); _flatContainerRepo = A.Fake <IFlatContainerRepository>(); var simulationFlatContainer = NewFC(3, Constants.ROOT, "SIMULATION", null, "", ""); var organFlatContainer = NewFC(1, "C1", "ORGAN", 3, "SIMULATION", Constants.ROOT); var compartmentFlatContainer = NewFC(2, "C2", "COMPARTMENT", 1, "C1", "ORGAN"); A.CallTo(() => _flatContainerRepo.All()).Returns( new List <FlatContainer> { organFlatContainer, compartmentFlatContainer, simulationFlatContainer }); A.CallTo(() => _flatContainerRepo.ParentContainerFrom(organFlatContainer.Id)).Returns(simulationFlatContainer); A.CallTo(() => _flatContainerRepo.ParentContainerFrom(compartmentFlatContainer.Id)).Returns(organFlatContainer); A.CallTo(() => _flatContainerRepo.ParentContainerFrom(simulationFlatContainer.Id)).Returns(null); A.CallTo(() => _flatContainerRepo.ContainerFrom(organFlatContainer.Id)).Returns(organFlatContainer); A.CallTo(() => _flatContainerRepo.ContainerFrom(compartmentFlatContainer.Id)).Returns(compartmentFlatContainer); A.CallTo(() => _flatContainerRepo.ContainerFrom(simulationFlatContainer.Id)).Returns(simulationFlatContainer); _flatModelCompartment = new FlatModelContainer { Id = compartmentFlatContainer.Id }; A.CallTo(() => _flatContainerRepo.ContainerFrom("ROOT")).Returns(organFlatContainer); A.CallTo(() => _flatContainerRepo.ContainerFrom("C1")).Returns(organFlatContainer); A.CallTo(() => _modelContainerRepo.AllSubContainerFor("M1", 1)).Returns(new[] { _flatModelCompartment }); A.CallTo(() => _flatContainerIdToContainerMapper.MapFrom(_flatModelCompartment)).Returns(_compartment); sut = new ModelContainerQuery(_modelContainerRepo, _populationContainerRepo, _flatContainerRepo, _flatContainerIdToContainerMapper, _entityPathResolver); }