public void should_create_one_value_point_for_each_point_defined_in_the_snapshot_formula()
        {
            _newTableFormula.AllPoints().Count().ShouldBeEqualTo(_tableFormula.AllPoints().Count());

            for (int i = 0; i < _newTableFormula.AllPoints().Count(); i++)
            {
                var p1 = _newTableFormula.AllPoints().ElementAt(i);
                var p2 = _tableFormula.AllPoints().ElementAt(i);
                p1.X.ShouldBeEqualTo(p2.X);
                p1.Y.ShouldBeEqualTo(p2.Y);
                p1.RestartSolver.ShouldBeEqualTo(p2.RestartSolver);
            }
        }
示例#2
0
 /// <summary>
 ///    Add the TableFormula representing the aging data for the individual with index <paramref name="individualIndex" />
 ///    and the parameter
 ///    with path <paramref name="parameterPath" />.
 /// </summary>
 /// <param name="parameterPath">Parameter full path</param>
 /// <param name="individualIndex">Index of individual</param>
 /// <param name="tableFormula">TableFormula representing the growth function for the parameter</param>
 public virtual void AddAgingTableFormula(string parameterPath, int individualIndex, TableFormula tableFormula)
 {
     foreach (var point in tableFormula.AllPoints())
     {
         AgingData.Add(individualIndex, parameterPath, point.X, point.Y);
     }
 }
        protected override Task Context()
        {
            _formulaFactory      = A.Fake <IFormulaFactory>();
            _dimensionRepository = A.Fake <IDimensionRepository>();

            sut = new TableFormulaMapper(_formulaFactory, _dimensionRepository);

            _tableFormula = new TableFormula
            {
                XName      = "pH",
                YName      = "Value",
                XDimension = DomainHelperForSpecs.TimeDimensionForSpecs(),
                Dimension  = DomainHelperForSpecs.LengthDimensionForSpecs(),
                Name       = "SUPER_FORMULA"
            };

            _tableFormula.XDisplayUnit = _tableFormula.XDimension.Unit("h");
            _tableFormula.YDisplayUnit = _tableFormula.Dimension.Unit("cm");

            _tableFormula.UseDerivedValues = true;

            _tableFormula.AddPoint(60, 1);  //60 min, 1m
            _tableFormula.AddPoint(120, 2); //120 min, 2m
            _tableFormula.AllPoints().ElementAt(1).RestartSolver = true;

            A.CallTo(() => _dimensionRepository.DimensionByName(_tableFormula.XDimension.Name)).Returns(_tableFormula.XDimension);
            A.CallTo(() => _dimensionRepository.DimensionByName(_tableFormula.Dimension.Name)).Returns(_tableFormula.Dimension);

            return(Task.FromResult(true));
        }
示例#4
0
 private void reportFor(TableFormula tableFormula, int noOfTabs)
 {
     foreach (var valuePoint in tableFormula.AllPoints())
     {
         _report.AppendFormat("{0}{1}; {2}   RestartSolver = {3}", tabs(noOfTabs), valuePoint.X, valuePoint.Y, valuePoint.RestartSolver);
         _report.AppendLine();
     }
 }
示例#5
0
        public DataRepository MapFrom(TableFormula tableFormula)
        {
            var dataRepository = new DataRepository(_idGenerator.NewId()).WithName(tableFormula.Name);
            var baseGrid       = new BaseGrid(_idGenerator.NewId(), tableFormula.XDimension.Name, tableFormula.XDimension)
            {
                DataInfo = { DisplayUnitName = tableFormula.XDisplayUnit.Name }
            };
            var value = new DataColumn(_idGenerator.NewId(), tableFormula.Name, tableFormula.Dimension, baseGrid)
            {
                DataInfo = { DisplayUnitName = tableFormula.YDisplayUnit.Name }
            };

            baseGrid.Values = tableFormula.AllPoints().Select(x => x.X).ToFloatArray();
            value.Values    = tableFormula.AllPoints().Select(x => x.Y).ToFloatArray();

            dataRepository.Add(value);
            return(dataRepository);
        }
        public bool AreEqualTableFormula(TableFormula formula, TableFormula allreadyUsedFormula)
        {
            var valuePoints = allreadyUsedFormula.AllPoints();

            if (!valuePoints.Count().Equals(formula.AllPoints().Count()))
            {
                return(false);
            }

            foreach (ValuePoint point in formula.AllPoints())
            {
                if (valuePoints.FirstOrDefault(p => p.X.Equals(point.X) && p.Y.Equals(point.Y)) == null)
                {
                    return(false);
                }
            }
            return(true);
        }
        public TableFormulaExport MapFrom(TableFormula input)
        {
            var export = new TableFormulaExport();

            input.AllPoints().Each(export.AddPoint);

            export.UseDerivedValues = input.UseDerivedValues;

            return(export);
        }
        public TableFormulaBuilderDTO MapFrom(TableFormula tableFormula)
        {
            var dto = Map <TableFormulaBuilderDTO>(tableFormula);

            dto.Dimension        = tableFormula.Dimension;
            dto.UseDerivedValues = tableFormula.UseDerivedValues;
            dto.XDisplayName     = Constants.NameWithUnitFor(tableFormula.XName, tableFormula.XDisplayUnit);
            dto.YDisplayName     = Constants.NameWithUnitFor(tableFormula.YName, tableFormula.YDisplayUnit);
            _valuePointToDTOValuePointMapperMapper.Initialise(tableFormula.XDimension, tableFormula.Dimension, tableFormula.XDisplayUnit, tableFormula.YDisplayUnit, dto);
            dto.ValuePoints = tableFormula.AllPoints().MapAllUsing(_valuePointToDTOValuePointMapperMapper);
            return(dto);
        }
        private void editFormula(TableFormula tableFormula)
        {
            _editedFormula = tableFormula ?? CreateTableFormula();
            if (_allPoints != null)
            {
                _allPoints.CollectionChanged -= notifyChange;
            }

            _allPoints = new NotifyList <ValuePointDTO>();
            _editedFormula.AllPoints().Each(p => _allPoints.Add(new ValuePointDTO(_tableParameter, _editedFormula, p)));

            string yName = string.IsNullOrEmpty(_editedFormula.YName) ? _tableParameter.Name : _editedFormula.YName;

            _view.XCaption = Constants.NameWithUnitFor(_editedFormula.XName, _editedFormula.XDisplayUnit);
            _view.YCaption = Constants.NameWithUnitFor(yName, _editedFormula.YDisplayUnit);

            _view.BindTo(_allPoints);

            _allPoints.CollectionChanged += notifyChange;
            if (tableFormula == null)
            {
                ViewChanged();
            }
        }
 public void should_return_a_table_formula_containing_a_solubility_for_each_half_ph()
 {
     _tableFormula.AllPoints().Count().ShouldBeEqualTo(14 * 2 + 1);
 }
示例#11
0
 public static ValuePoint GetPointWithCoordinates(this TableFormula formula, double x, double y)
 {
     return(formula.AllPoints().Single(point => ValueComparer.AreValuesEqual(point.X, x) && ValueComparer.AreValuesEqual(point.Y, y)));
 }