Example #1
0
        protected override void Context()
        {
            _msvCreator = A.Fake <IMoleculeStartValuesCreator>();

            A.CallTo(() => _msvCreator.CreateMoleculeStartValue(A <IObjectPath> .Ignored, A <string> .Ignored, A <IDimension> .Ignored, A <Unit> ._, A <ValueOrigin> ._))
            .ReturnsLazily((IObjectPath path, string moleculeName, IDimension dimension) => new MoleculeStartValue {
                ContainerPath = path, Name = moleculeName, Dimension = dimension
            });

            _concentrationDimension = new Dimension(new BaseDimensionRepresentation(), Constants.Dimension.MOLAR_CONCENTRATION, "mol/l");

            _amountDimension = new Dimension(new BaseDimensionRepresentation(), Constants.Dimension.AMOUNT, "mol");
            _amountDimension.AddUnit("mmol", 0.001, 0);

            _timeDimension = new Dimension(new BaseDimensionRepresentation(), Constants.Dimension.TIME, "s");
            _timeDimension.Unit("s").Factor = 1.0 / 60;

            _dimensionFactory         = A.Fake <IMoBiDimensionFactory>();
            _startValuesBuildingBlock = A.Fake <IMoleculeStartValuesBuildingBlock>();

            _reactionDimensionRetriever = A.Fake <IReactionDimensionRetriever>();

            A.CallTo(() => _dimensionFactory.DimensionForUnit("mol")).Returns(_amountDimension);
            A.CallTo(() => _dimensionFactory.DimensionForUnit("mmol")).Returns(_amountDimension);
            A.CallTo(() => _dimensionFactory.DimensionForUnit("mol/l")).Returns(_concentrationDimension);
            A.CallTo(() => _dimensionFactory.DimensionForUnit("s")).Returns(_timeDimension);
            A.CallTo(() => _dimensionFactory.DimensionForUnit("")).Throws <Exception>();

            A.CallTo(() => _dimensionFactory.Dimension(Constants.Dimension.AMOUNT)).Returns(_amountDimension);
            A.CallTo(() => _dimensionFactory.Dimension(Constants.Dimension.MOLAR_CONCENTRATION)).Returns(_concentrationDimension);

            A.CallTo(() => _reactionDimensionRetriever.SelectedDimensionMode).Returns(ReactionDimensionMode.AmountBased);

            sut = new DataTableToImportQuantityDTOMapperForMolecules(_dimensionFactory, _reactionDimensionRetriever);
        }
        public IMoleculeStartValue MapFrom(ImportedQuantityDTO input)
        {
            var msv = _msvCreator.CreateMoleculeStartValue(input.ContainerPath, input.Name, input.Dimension, input.DisplayUnit);

            msv.StartValue            = input.QuantityInBaseUnit;
            msv.DisplayUnit           = input.DisplayUnit;
            msv.IsPresent             = input.IsPresent;
            msv.NegativeValuesAllowed = input.NegativeValuesAllowed;

            if (input.IsQuantitySpecified)
            {
                msv.StartValue = input.QuantityInBaseUnit;
            }

            if (input.IsScaleDivisorSpecified)
            {
                msv.ScaleDivisor = input.ScaleDivisor;
            }

            return(msv);
        }
        private IBuildConfiguration createBuildConfiguration()
        {
            var buildConfiguration = new BuildConfigurationForSpecs();

            buildConfiguration.Molecules          = getMolecules();
            buildConfiguration.Reactions          = getReactions();
            buildConfiguration.SpatialStructure   = getSpatialStructure();
            buildConfiguration.PassiveTransports  = new PassiveTransportBuildingBlock();
            buildConfiguration.Observers          = new ObserverBuildingBlock();
            buildConfiguration.EventGroups        = new EventGroupBuildingBlock();
            buildConfiguration.SimulationSettings = createSimulationConfiguration();


            buildConfiguration.MoleculeStartValues = _moleculeStartValuesCreator.CreateFrom(buildConfiguration.SpatialStructure, buildConfiguration.Molecules);
            var objectPathForContainerThatDoesNotExist = _objectPathFactory.CreateObjectPathFrom("TOTO", "TATA");

            buildConfiguration.MoleculeStartValues.Add(_moleculeStartValuesCreator.CreateMoleculeStartValue(objectPathForContainerThatDoesNotExist, "A", _concentrationDimension));
            buildConfiguration.ParameterStartValues = _parameterStartValuesCreator.CreateFrom(buildConfiguration.SpatialStructure, buildConfiguration.Molecules);

            setMoleculeStartValues(buildConfiguration.MoleculeStartValues);
            return(buildConfiguration);
        }