Skip to content

Commit

Permalink
Fixes #2118 calculated values show error (#2220)
Browse files Browse the repository at this point in the history
  • Loading branch information
msevestre authored May 2, 2022
1 parent 1dd368a commit d93ea7c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
20 changes: 0 additions & 20 deletions src/PKSim.Assets/PKSimConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1469,26 +1469,6 @@ public static string MinLessThanDbMaxValue(string parameterName, string displayM
return $"Minimum value for {parameterName} should be less than or equal to {displayMaxValue} {unit}.";
}

public static string ValueSmallerThanMax(string parameterName, string value, string unit)
{
return $"Value for {parameterName} should be less than or equal to {value} {unit}";
}

public static string ValueBiggerThanMin(string parameterName, string value, string unit)
{
return $"Value for {parameterName} should be greater than or equal to {value} {unit}";
}

public static string ValueStrictBiggerThanMin(string parameterName, string value, string unit)
{
return $"Value for {parameterName} should be strictly greater than {value} {unit}";
}

public static string ValueStrictSmallerThanMax(string parameterName, string value, string unit)
{
return $"Value for {parameterName} should be strictly less than {value} {unit}";
}

public static readonly string ProportionOfFemaleBetween0And100 = "Proportion of females should be between 0 and 100";
public static readonly string NumberOfIndividualShouldBeBiggerThan2 = "Number of individuals should be greater than or equal to 2";
public static readonly string NumberOfIndividualShouldBeSmallerThan10000 = "Number of individuals should be less than or equal to 10000";
Expand Down
8 changes: 6 additions & 2 deletions src/PKSim.Presentation/DTO/Parameters/ParameterDTO.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using OSPSuite.Utility.Collections;
using OSPSuite.Utility.Validation;
Expand Down Expand Up @@ -78,8 +77,13 @@ public virtual double Value
{
get
{
var (result,_) = Parameter.TryGetValueInDisplayUnit();
var (result, success) = Parameter.TryGetValueInDisplayUnit();
//Permeability cannot be read in compound as references cannot be resolved
//We return zero for now so that the rules are not showing a broken state (>=0).
//We probably need to update the rules framework to not evaluate on NaN.
if (!success)
return 0;

return result;

}
Expand Down
2 changes: 2 additions & 0 deletions src/PKSim.UI/Views/Core/CalculationMethodSelectionViewBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public override void InitializeBinding()
public void BindTo(IEnumerable<CategoryCalculationMethodDTO> calculationMethodDtos)
{
_gridViewBinder.BindToSource(calculationMethodDtos);
//This is required to ensure that the view resizes itself as expected
AdjustHeight();
}

private void onToolTipControllerGetActiveObjectInfo(object sender, ToolTipControllerGetActiveObjectInfoEventArgs e)
Expand Down
22 changes: 19 additions & 3 deletions tests/PKSim.Tests/Presentation/ParameterDTOSpecs.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.ComponentModel;
using FakeItEasy;
using PKSim.Presentation.DTO.Parameters;
using OSPSuite.BDDHelper;
using OSPSuite.BDDHelper.Extensions;
using OSPSuite.Core.Domain;
using OSPSuite.Core.Domain.Formulas;
using OSPSuite.Utility.Validation;
using PKSim.Presentation.DTO.Parameters;

namespace PKSim.Presentation
{
Expand Down Expand Up @@ -51,7 +52,7 @@ public void should_propagate_the_event()
}
}

public class When_perfoming_validation_for_a_given_property : concern_for_ParameterDTO
public class When_performing_validation_for_a_given_property : concern_for_ParameterDTO
{
private double _valueInDisplayUnit;
private double _kernelValue;
Expand All @@ -78,7 +79,7 @@ public void should_use_the_validation_rules_defined_in_the_underlying_parameter(
}
}

public class When_perfoning_validation_for_a_given_property_for_a_parameter_that_is_not_editable : concern_for_ParameterDTO
public class When_performing_validation_for_a_given_property_for_a_parameter_that_is_not_editable : concern_for_ParameterDTO
{
private double _valueToValidate;

Expand Down Expand Up @@ -166,4 +167,19 @@ public void should_return_the_value_of_the_parameter()
sut.KernelValue.ShouldBeEqualTo(_parameter.Value);
}
}

public class When_retrieving_the_value_of_a_parameter_dto_for_which_the_underlying_parameter_formula_cannot_be_computed : concern_for_ParameterDTO
{
protected override void Context()
{
base.Context();
_parameter.Formula = new ExplicitFormula("A + 5");
}

[Observation]
public void should_return_a_value_of_zero()
{
sut.Value.ShouldBeEqualTo(0);
}
}
}

0 comments on commit d93ea7c

Please sign in to comment.