Пример #1
0
        protected override void Context()
        {
            base.Context();
            _templateStartValues = new ParameterStartValuesBuildingBlock();

            _containerPath = new ObjectPath("the", "container", "path");

            _parameterStartValueBuildingBlock.Add(
                new ParameterStartValue {
                StartValue = 0.1, ContainerPath = _containerPath.Clone <IObjectPath>(), Name = "ConstantStartValue"
            });

            _parameterStartValue = new ParameterStartValue {
                ContainerPath = _containerPath.Clone <IObjectPath>(), Name = "FormulaStartValue", StartValue = 4
            };
            _clonedStartValue = new ParameterStartValue {
                ContainerPath = _containerPath.Clone <IObjectPath>(), Name = "FormulaStartValue", StartValue = 4
            };

            _templateStartValues.Add(_parameterStartValue);
            _templateStartValues.Add(new ParameterStartValue {
                StartValue = 0.4, ContainerPath = _containerPath.Clone <IObjectPath>(), Name = "ConstantStartValue"
            });

            A.CallTo(() => _cloneManagerForBuildingBlock.Clone(_parameterStartValue, A <IFormulaCache> .Ignored)).Returns(_clonedStartValue);
        }
 protected override void Context()
 {
     base.Context();
     _parameterStartValuesBuildingBlock      = new ParameterStartValuesBuildingBlock();
     _parameterStartValuesBuildingBlock.Name = _changedName;
     _parameterStartValue = new ParameterStartValue();
     _path = new ObjectPath(new[] { "A", "B", _changedName });
     _parameterStartValue.Path = _path;
     _parameterStartValuesBuildingBlock.Add(_parameterStartValue);
     _parameterStartValue2 = new ParameterStartValue();
     _path = new ObjectPath(new[] { "A", _changedName, "B" });
     _parameterStartValue2.Path = _path;
     _parameterStartValuesBuildingBlock.Add(_parameterStartValue2);
     _project.AddBuildingBlock(_parameterStartValuesBuildingBlock);
 }
Пример #3
0
 private void addMoleculeParameterValues(IParameterStartValuesBuildingBlock parameterStartValuesBuildingBlock,
                                         ISpatialStructure spatialStructure, IEnumerable <IMoleculeBuilder> moleculeBuilderCollection)
 {
     foreach (var paramValue in moleculeBuilderCollection.SelectMany(moleculeBuilder => getMoleculeParameterValues(spatialStructure, moleculeBuilder)))
     {
         parameterStartValuesBuildingBlock.Add(paramValue);
     }
 }
 public void Visit(IParameterStartValuesBuildingBlock parameterStartValuesBuilding)
 {
     foreach (var parameterStartValue in parameterStartValuesBuilding.OfType <ParameterStartValue>().ToList())
     {
         //psv stored as a cache using path as key
         parameterStartValuesBuilding.Remove(parameterStartValue);
         parameterStartValue.Path = parameterStartValue.ContainerPath;
         parameterStartValuesBuilding.Add(parameterStartValue);
     }
 }
 protected override void Context()
 {
     base.Context();
     _context             = A.Fake <IMoBiContext>();
     _buildingBlock       = new ParameterStartValuesBuildingBlock();
     _parameterStartValue = new ParameterStartValue();
     _path = new ObjectPath("A", "B");
     _parameterStartValue.ContainerPath = _path;
     _parameterStartValue.Name          = "Name";
     _buildingBlock.Add(_parameterStartValue);
 }
Пример #6
0
        private void addGlobalMoleculeParameterValues(IParameterStartValuesBuildingBlock parameterStartValuesBuildingBlock, IContainer globalMoleculeDependentProperties, IMoleculeBuildingBlock moleculeBuildingBlock)
        {
            var globalParameter = globalMoleculeDependentProperties.GetChildren <IParameter>(parameterValueShouldBeSet);

            foreach (var parameter in globalParameter)
            {
                foreach (var moleculeBuilder in moleculeBuildingBlock)
                {
                    parameterStartValuesBuildingBlock.Add(globalMoleculeParameterValueFor(moleculeBuilder, parameter));
                }
            }
        }
Пример #7
0
        protected override void Context()
        {
            _context       = A.Fake <IMoBiContext>();
            _buildingBlock = new ParameterStartValuesBuildingBlock();

            _path = new ObjectPath(new[] { string.Format("path{0}", 1) });
            _buildingBlock.Add(new ParameterStartValue {
                Path = _path, StartValue = -1, DisplayUnit = new Unit("Dimensionless", 1.0, 1)
            });

            sut = new UpdateParameterStartValueInBuildingBlockCommand(_buildingBlock, _path, 1.0);
            A.CallTo(() => _context.Get <IParameterStartValuesBuildingBlock>(_buildingBlock.Id)).Returns(_buildingBlock);
        }
        private IParameterStartValue trySetValue(IParameter parameter)
        {
            var parameterPath = _entityPathResolver.ObjectPathFor(parameter);

            if (_defaultStartValues[parameterPath] != null)
            {
                return(trySetValue(parameterPath, parameter));
            }

            var parameterStartValue = _parameterStartValuesCreator.CreateParameterStartValue(parameterPath, parameter);

            _defaultStartValues.Add(parameterStartValue);
            return(parameterStartValue);
        }
Пример #9
0
        /// <summary>
        ///    Adds neighborhood value parameters.
        /// </summary>
        private void addContainerListParameterValue(IParameterStartValuesBuildingBlock parameterStartValuesBuildingBlock,
                                                    IEnumerable <IContainer> neighborhoodBuilders, IMoleculeBuildingBlock moleculeBuildingBlock)
        {
            foreach (var neighborhood in neighborhoodBuilders)
            {
                var parameters = neighborhood.GetChildren <IParameter>(parameterValueShouldBeSet);
                parameters.Each(param => parameterStartValuesBuildingBlock.Add(containerParameterValueFor(param)));

                var moleculeProperties = neighborhood.GetSingleChildByName <IContainer>(Constants.MOLECULE_PROPERTIES);
                if (moleculeProperties == null)
                {
                    continue;
                }

                foreach (
                    var paramValue in
                    moleculeBuildingBlock.SelectMany(
                        moleculeBuilder => getMoleculePropertiesParameterValues(moleculeProperties, moleculeBuilder)))
                {
                    parameterStartValuesBuildingBlock.Add(paramValue);
                }
            }
        }
        protected override void Context()
        {
            base.Context();
            _psvbb = new ParameterStartValuesBuildingBlock();
            _psv1  = new ParameterStartValue {
                Path = new ObjectPath("A")
            };
            _project = A.Fake <IMoBiProject>();

            _psv2 = new ParameterStartValue {
                Path = new ObjectPath("B")
            };
            _psv3 = new ParameterStartValue {
                Path = new ObjectPath(Constants.Distribution.GEOMETRIC_DEVIATION)
            };
            _psvbb.Add(_psv1);
            _psvbb.Add(_psv2);
            _psvbb.Add(_psv3);
            _startValue      = 2;
            _psv3.StartValue = _startValue;
            _dim             = A.Fake <IDimension>();
            A.CallTo(_dimensionRetriever).WithReturnType <IDimension>().Returns(_dim);
        }
        protected override void Context()
        {
            _context       = A.Fake <IMoBiContext>();
            _buildingBlock = new ParameterStartValuesBuildingBlock();

            _psv = new ParameterStartValue {
                Path = new ObjectPath("path1"), StartValue = -1, DisplayUnit = new Unit("Dimensionless", 1.0, 1)
            };
            _buildingBlock.Add(_psv);
            sut = new RemoveParameterStartValueFromBuildingBlockCommand(_buildingBlock, _psv.Path);

            A.CallTo(() => _context.Deserialize <IParameterStartValue>(A <byte[]> ._)).Returns(_psv);
            A.CallTo(() => _context.Get <IStartValuesBuildingBlock <IParameterStartValue> >(_buildingBlock.Id)).Returns(_buildingBlock);
        }
Пример #12
0
        private IParameterStartValue getOrCreateStartValueFor(IParameter parameter)
        {
            var parameterPath       = _entityPathResolver.ObjectPathFor(parameter);
            var parameterStartValue = _defaultStartValues[parameterPath];

            if (parameterStartValue != null)
            {
                return(parameterStartValue);
            }

            parameterStartValue = _parameterStartValuesCreator.CreateParameterStartValue(parameterPath, parameter);
            _defaultStartValues.Add(parameterStartValue);

            return(parameterStartValue);
        }