Index: Riskeer/DuneErosion/src/Riskeer.DuneErosion.Service/DuneLocationCalculationActivity.cs
===================================================================
diff -u -re3c8135a137a664bc323012ca829d606ebee6bff -r01594ac7a38dac4d0d9c45c4778affd651e01781
--- Riskeer/DuneErosion/src/Riskeer.DuneErosion.Service/DuneLocationCalculationActivity.cs (.../DuneLocationCalculationActivity.cs) (revision e3c8135a137a664bc323012ca829d606ebee6bff)
+++ Riskeer/DuneErosion/src/Riskeer.DuneErosion.Service/DuneLocationCalculationActivity.cs (.../DuneLocationCalculationActivity.cs) (revision 01594ac7a38dac4d0d9c45c4778affd651e01781)
@@ -34,7 +34,7 @@
{
private readonly DuneLocationCalculation duneLocationCalculation;
private readonly HydraulicBoundaryCalculationSettings calculationSettings;
- private readonly double norm;
+ private readonly double targetProbability;
private readonly ICalculationMessageProvider messageProvider;
private readonly DuneLocationCalculationService calculationService;
@@ -44,28 +44,28 @@
/// The to perform.
/// The with the
/// hydraulic boundary calculation settings.
- /// The norm to use during the calculation.
- /// The name of the category boundary.
+ /// The target probability to use during the calculation.
+ /// The calculation identifier to use in all messages.
/// Preprocessing is disabled when the preprocessor directory equals .
/// Thrown when
/// or is null.
- /// Thrown when is null or empty.
+ /// Thrown when is null or empty.
public DuneLocationCalculationActivity(DuneLocationCalculation duneLocationCalculation,
HydraulicBoundaryCalculationSettings calculationSettings,
- double norm,
- string categoryBoundaryName)
+ double targetProbability,
+ string calculationIdentifier)
: base(duneLocationCalculation)
{
if (calculationSettings == null)
{
throw new ArgumentNullException(nameof(calculationSettings));
}
- messageProvider = new DuneLocationCalculationMessageProvider(categoryBoundaryName);
+ messageProvider = new DuneLocationCalculationMessageProvider(calculationIdentifier);
this.duneLocationCalculation = duneLocationCalculation;
this.calculationSettings = calculationSettings;
- this.norm = norm;
+ this.targetProbability = targetProbability;
DuneLocation duneLocation = duneLocationCalculation.DuneLocation;
Description = messageProvider.GetActivityDescription(duneLocation.Name);
@@ -75,13 +75,13 @@
protected override bool Validate()
{
- return calculationService.Validate(calculationSettings, norm);
+ return calculationService.Validate(calculationSettings, targetProbability);
}
protected override void PerformCalculation()
{
calculationService.Calculate(duneLocationCalculation,
- norm,
+ targetProbability,
calculationSettings,
messageProvider);
}
Index: Riskeer/DuneErosion/test/Riskeer.DuneErosion.Service.Test/DuneLocationCalculationActivityTest.cs
===================================================================
diff -u -r28153d7db0a46b836af1fe070cdd674c856d565d -r01594ac7a38dac4d0d9c45c4778affd651e01781
--- Riskeer/DuneErosion/test/Riskeer.DuneErosion.Service.Test/DuneLocationCalculationActivityTest.cs (.../DuneLocationCalculationActivityTest.cs) (revision 28153d7db0a46b836af1fe070cdd674c856d565d)
+++ Riskeer/DuneErosion/test/Riskeer.DuneErosion.Service.Test/DuneLocationCalculationActivityTest.cs (.../DuneLocationCalculationActivityTest.cs) (revision 01594ac7a38dac4d0d9c45c4778affd651e01781)
@@ -44,8 +44,6 @@
[TestFixture]
public class DuneLocationCalculationActivityTest
{
- private const double validNorm = 0.005;
-
private MockRepository mockRepository;
private static readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Integration.Service, "HydraRingCalculation");
private static readonly string validHydraulicBoundaryDatabaseFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite");
@@ -61,37 +59,33 @@
[Test]
public void Constructor_CalculationSettingsNull_ThrowsArgumentNullException()
{
- // Setup
- const string locationName = "locationName";
- const string categoryBoundaryName = "A";
-
// Call
- TestDelegate call = () => new DuneLocationCalculationActivity(new DuneLocationCalculation(new TestDuneLocation(locationName)),
- null,
- 1,
- categoryBoundaryName);
+ void Call() => new DuneLocationCalculationActivity(new DuneLocationCalculation(new TestDuneLocation("locationName")),
+ null,
+ 0.01,
+ "1/100");
// Assert
- var exception = Assert.Throws(call);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("calculationSettings", exception.ParamName);
}
[Test]
public void Constructor_ExpectedValues()
{
// Setup
- const string categoryBoundaryName = "A";
+ const string calculationIdentifier = "1/100";
const string locationName = "locationName";
// Call
var activity = new DuneLocationCalculationActivity(new DuneLocationCalculation(new TestDuneLocation(locationName)),
CreateCalculationSettings(),
- 1.0 / 30000,
- categoryBoundaryName);
+ 0.001,
+ calculationIdentifier);
// Assert
Assert.IsInstanceOf(activity);
- Assert.AreEqual($"Hydraulische belastingen berekenen voor locatie '{locationName}' ({categoryBoundaryName})", activity.Description);
+ Assert.AreEqual($"Hydraulische belastingen berekenen voor locatie '{locationName}' ({calculationIdentifier})", activity.Description);
Assert.IsNull(activity.ProgressText);
Assert.AreEqual(ActivityState.None, activity.State);
}
@@ -102,7 +96,7 @@
// Setup
string invalidFilePath = Path.Combine(testDataPath, "notexisting.sqlite");
- const string categoryBoundaryName = "A";
+ const string calculationIdentifier = "1/100";
const string locationName = "locationName";
var settings = new HydraulicBoundaryCalculationSettings(invalidFilePath,
@@ -111,18 +105,18 @@
string.Empty);
var activity = new DuneLocationCalculationActivity(new DuneLocationCalculation(new TestDuneLocation(locationName)),
settings,
- 0.5,
- categoryBoundaryName);
+ 0.01,
+ calculationIdentifier);
// Call
- Action call = () => activity.Run();
+ void Call() => activity.Run();
// Assert
- TestHelper.AssertLogMessages(call, messages =>
+ TestHelper.AssertLogMessages(Call, messages =>
{
string[] msgs = messages.ToArray();
Assert.AreEqual(4, msgs.Length);
- Assert.AreEqual($"Hydraulische belastingen berekenen voor locatie '{locationName}' ({categoryBoundaryName}) is gestart.", msgs[0]);
+ Assert.AreEqual($"Hydraulische belastingen berekenen voor locatie '{locationName}' ({calculationIdentifier}) is gestart.", msgs[0]);
CalculationServiceTestHelper.AssertValidationStartMessage(msgs[1]);
StringAssert.StartsWith("Herstellen van de verbinding met de hydraulische belastingendatabase is mislukt. Fout bij het lezen van bestand", msgs[2]);
CalculationServiceTestHelper.AssertValidationEndMessage(msgs[3]);
@@ -134,7 +128,7 @@
public void Run_InvalidPreprocessorDirectory_PerformValidationAndLogStartAndEndAndError()
{
// Setup
- const string categoryBoundaryName = "A";
+ const string calculationIdentifier = "1/100";
const string locationName = "locationName";
var settings = new HydraulicBoundaryCalculationSettings(validHydraulicBoundaryDatabaseFilePath,
@@ -143,18 +137,18 @@
"NonExistingPreprocessorDirectory");
var activity = new DuneLocationCalculationActivity(new DuneLocationCalculation(new TestDuneLocation(locationName)),
settings,
- 0.5,
- categoryBoundaryName);
+ 0.01,
+ calculationIdentifier);
// Call
- Action call = () => activity.Run();
+ void Call() => activity.Run();
// Assert
- TestHelper.AssertLogMessages(call, messages =>
+ TestHelper.AssertLogMessages(Call, messages =>
{
string[] msgs = messages.ToArray();
Assert.AreEqual(4, msgs.Length);
- Assert.AreEqual($"Hydraulische belastingen berekenen voor locatie '{locationName}' ({categoryBoundaryName}) is gestart.", msgs[0]);
+ Assert.AreEqual($"Hydraulische belastingen berekenen voor locatie '{locationName}' ({calculationIdentifier}) is gestart.", msgs[0]);
CalculationServiceTestHelper.AssertValidationStartMessage(msgs[1]);
Assert.AreEqual("De bestandsmap waar de preprocessor bestanden opslaat is ongeldig. De bestandsmap bestaat niet.", msgs[2]);
CalculationServiceTestHelper.AssertValidationEndMessage(msgs[3]);
@@ -163,26 +157,26 @@
}
[Test]
- public void Run_InvalidNorm_PerformValidationAndLogStartAndEndAndError()
+ public void Run_InvalidTargetProbability_PerformValidationAndLogStartAndEndAndError()
{
// Setup
- const string categoryBoundaryName = "A";
+ const string calculationIdentifier = "1/1";
const string locationName = "locationName";
var activity = new DuneLocationCalculationActivity(new DuneLocationCalculation(new TestDuneLocation(locationName)),
CreateCalculationSettings(),
1.0,
- categoryBoundaryName);
+ calculationIdentifier);
// Call
- Action call = () => activity.Run();
+ void Call() => activity.Run();
// Assert
- TestHelper.AssertLogMessages(call, messages =>
+ TestHelper.AssertLogMessages(Call, messages =>
{
string[] msgs = messages.ToArray();
Assert.AreEqual(4, msgs.Length);
- Assert.AreEqual($"Hydraulische belastingen berekenen voor locatie '{locationName}' ({categoryBoundaryName}) is gestart.", msgs[0]);
+ Assert.AreEqual($"Hydraulische belastingen berekenen voor locatie '{locationName}' ({calculationIdentifier}) is gestart.", msgs[0]);
CalculationServiceTestHelper.AssertValidationStartMessage(msgs[1]);
Assert.AreEqual("Doelkans is te groot om een berekening uit te kunnen voeren.", msgs[2]);
CalculationServiceTestHelper.AssertValidationEndMessage(msgs[3]);
@@ -196,8 +190,8 @@
public void Run_VariousValidInputs_PerformsCalculationWithCorrectInput(bool usePreprocessor)
{
// Setup
- const double norm = 1.0 / 30;
- const string categoryBoundaryName = "A";
+ const double targetProbability = 0.01;
+ const string calculationIdentifier = "1/100";
const string locationName = "locationName";
var calculator = new TestDunesBoundaryConditionsCalculator
@@ -225,8 +219,8 @@
var activity = new DuneLocationCalculationActivity(new DuneLocationCalculation(duneLocation),
calculationSettings,
- norm,
- categoryBoundaryName);
+ targetProbability,
+ calculationIdentifier);
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
@@ -236,7 +230,7 @@
// Assert
DunesBoundaryConditionsCalculationInput calculationInput = calculator.ReceivedInputs.Single();
Assert.AreEqual(duneLocation.Id, calculationInput.HydraulicBoundaryLocationId);
- Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(norm), calculationInput.Beta);
+ Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(targetProbability), calculationInput.Beta);
}
mockRepository.VerifyAll();
@@ -246,8 +240,8 @@
public void Run_ValidInput_PerformValidationAndCalculationAndLogStartAndEnd()
{
// Setup
- const double norm = 1.0 / 30;
- const string categoryBoundaryName = "A";
+ const double targetProbability = 0.01;
+ const string calculationIdentifier = "1/100";
const string locationName = "locationName";
var calculator = new TestDunesBoundaryConditionsCalculator
@@ -267,20 +261,20 @@
var activity = new DuneLocationCalculationActivity(new DuneLocationCalculation(duneLocation),
calculationSettings,
- norm,
- categoryBoundaryName);
+ targetProbability,
+ calculationIdentifier);
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
// Call
- Action call = () => activity.Run();
+ void Call() => activity.Run();
// Assert
- TestHelper.AssertLogMessages(call, m =>
+ TestHelper.AssertLogMessages(Call, m =>
{
string[] messages = m.ToArray();
Assert.AreEqual(6, messages.Length);
- Assert.AreEqual($"Hydraulische belastingen berekenen voor locatie '{locationName}' ({categoryBoundaryName}) is gestart.", messages[0]);
+ Assert.AreEqual($"Hydraulische belastingen berekenen voor locatie '{locationName}' ({calculationIdentifier}) is gestart.", messages[0]);
CalculationServiceTestHelper.AssertValidationStartMessage(messages[1]);
CalculationServiceTestHelper.AssertValidationEndMessage(messages[2]);
CalculationServiceTestHelper.AssertCalculationStartMessage(messages[3]);
@@ -321,8 +315,8 @@
var activity = new DuneLocationCalculationActivity(duneLocationCalculation,
CreateCalculationSettings(),
- validNorm,
- "A");
+ 0.01,
+ "1/100");
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
@@ -349,7 +343,7 @@
public void Run_InvalidCalculation_LogsError(bool endInFailure, string lastErrorFileContent)
{
// Setup
- const string categoryBoundaryName = "A";
+ const string calculationIdentifier = "1/100";
const string locationName = "locationName";
var calculator = new TestDunesBoundaryConditionsCalculator
@@ -366,20 +360,20 @@
var activity = new DuneLocationCalculationActivity(new DuneLocationCalculation(new TestDuneLocation(locationName)),
CreateCalculationSettings(),
- 0.5,
- categoryBoundaryName);
+ 0.01,
+ calculationIdentifier);
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
// Call
- Action call = () => activity.Run();
+ void Call() => activity.Run();
// Assert
string expectedFailureMessage = string.IsNullOrEmpty(lastErrorFileContent)
- ? $"Er is een fout opgetreden tijdens de hydraulische belastingenberekening '{locationName}' ({categoryBoundaryName}). Er is geen foutrapport beschikbaar."
- : $"Er is een fout opgetreden tijdens de hydraulische belastingenberekening '{locationName}' ({categoryBoundaryName}). Bekijk het foutrapport door op details te klikken.{Environment.NewLine}{lastErrorFileContent}";
+ ? $"Er is een fout opgetreden tijdens de hydraulische belastingenberekening '{locationName}' ({calculationIdentifier}). Er is geen foutrapport beschikbaar."
+ : $"Er is een fout opgetreden tijdens de hydraulische belastingenberekening '{locationName}' ({calculationIdentifier}). Bekijk het foutrapport door op details te klikken.{Environment.NewLine}{lastErrorFileContent}";
- TestHelper.AssertLogMessageIsGenerated(call, expectedFailureMessage, 7);
+ TestHelper.AssertLogMessageIsGenerated(Call, expectedFailureMessage, 7);
}
mockRepository.VerifyAll();
@@ -389,7 +383,7 @@
public void Run_CalculationResultingInNoConvergence_LogWarningNoConvergence()
{
// Setup
- const string categoryBoundaryName = "A";
+ const string calculationIdentifier = "1/100";
const string locationName = "locationName";
var calculator = new TestDunesBoundaryConditionsCalculator
@@ -407,19 +401,19 @@
var activity = new DuneLocationCalculationActivity(duneLocationCalculation,
CreateCalculationSettings(),
- 0.5,
- categoryBoundaryName);
+ 0.01,
+ calculationIdentifier);
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
- Action call = () => activity.Run();
+ void Call() => activity.Run();
// Assert
- TestHelper.AssertLogMessages(call, messages =>
+ TestHelper.AssertLogMessages(Call, messages =>
{
string[] msgs = messages.ToArray();
Assert.AreEqual(7, msgs.Length);
- Assert.AreEqual($"Hydraulische belastingenberekening voor locatie '{locationName}' ({categoryBoundaryName}) is niet geconvergeerd.", msgs[4]);
+ Assert.AreEqual($"Hydraulische belastingenberekening voor locatie '{locationName}' ({calculationIdentifier}) is niet geconvergeerd.", msgs[4]);
});
Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, duneLocationCalculation.Output.CalculationConvergence);
}
@@ -451,8 +445,8 @@
var activity = new DuneLocationCalculationActivity(new DuneLocationCalculation(new TestDuneLocation(locationName)),
CreateCalculationSettings(),
- 0.5,
- "A");
+ 0.01,
+ "1/100");
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
@@ -483,8 +477,8 @@
var activity = new DuneLocationCalculationActivityWithState(duneLocationCalculation,
CreateCalculationSettings(),
- 1.0,
- "A",
+ 0.01,
+ "1/100",
state);
// Call
@@ -506,13 +500,13 @@
{
public DuneLocationCalculationActivityWithState(DuneLocationCalculation duneLocationCalculation,
HydraulicBoundaryCalculationSettings calculationSettings,
- double norm,
- string categoryBoundaryName,
+ double targetProbability,
+ string calculationIdentifier,
ActivityState state)
: base(duneLocationCalculation,
calculationSettings,
- norm,
- categoryBoundaryName)
+ targetProbability,
+ calculationIdentifier)
{
State = state;
}