public void should_update_calculation_methods_with_2pores_calcmethods()
        {
            ModelProperties modelProperties2Pores = sut.DefaultFor(_originData, CoreConstants.Model.TwoPores);

            foreach (var calcMethod in modelProperties2Pores.AllCalculationMethods())
            {
                _updatedProperties.ContainsCalculationMethod(calcMethod.Name).ShouldBeTrue();
            }
        }
Exemple #2
0
        public ModelProperties Update(ModelProperties oldModelProperties, ModelProperties newModelProperties, OriginData originData)
        {
            if (oldModelProperties == null)
            {
                UpdateCategoriesIn(newModelProperties, originData);
                return(newModelProperties);
            }

            var oldModelConfig = oldModelProperties.ModelConfiguration;
            var newModelConfig = newModelProperties.ModelConfiguration;

            //same species and same model=>we can return the old one
            if (areCompatible(oldModelConfig, newModelConfig))
            {
                UpdateCategoriesIn(oldModelProperties, originData);
                return(oldModelProperties);
            }

            //in that case. Try to update as much CM as we can
            foreach (var calculationMethod in newModelProperties.AllCalculationMethods().ToList())
            {
                string category             = calculationMethod.Category;
                var    oldCalculationMethod = oldModelProperties.CalculationMethodFor(category);
                var    newCategory          = newModelConfig.CalculationMethodCategories.FindByName(category);

                if (oldCalculationMethod == null || !newCategory.AllItems().Contains(oldCalculationMethod))
                {
                    continue;
                }

                newModelProperties.RemoveCalculationMethod(calculationMethod);
                newModelProperties.AddCalculationMethod(oldCalculationMethod);
            }

            return(newModelProperties);
        }
Exemple #3
0
 private void updateModelProperties(ModelProperties modelProperties)
 {
     _view.UpdateModelImage(selectedModelConfiguration.ModelName);
     updateCalculationMethods(modelProperties.AllCalculationMethods());
 }
 public void AddModelParametersTo <TContainer>(TContainer parameterContainer, OriginData originData, ModelProperties modelProperties, IFormulaCache formulaCache) where TContainer : IContainer
 {
     addParametersTo(parameterContainer, originData, modelProperties.AllCalculationMethods().Select(cm => cm.Name), param => true, formulaCache);
 }
 public void should_return_a_model_properties_configured_with_the_selected_calculation_methods()
 {
     _result.AllCalculationMethods().ShouldOnlyContain(_cm1, _cm2);
 }
 public void should_return_a_model_properties_containing_the_default_calculation_method_for_the_species()
 {
     _result.AllCalculationMethods().ShouldOnlyContainInOrder(_cm1, _cm2);
 }
 public void should_return_the_later_model_propertie_and_try_to_update_the_common_properties()
 {
     _result.ShouldBeEqualTo(_newModelProperties);
     _result.AllCalculationMethods().ShouldContain(_c1);
     _result.AllCalculationMethods().ShouldContain(_c3);
 }
 public void should_return_the_former_model_propertie_without_changing_any_selected_calculation_method()
 {
     _result.ShouldBeEqualTo(_oldModelProperties);
     _result.AllCalculationMethods().ShouldContain(_c1);
 }