Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Integration.Test/ClosingStructuresCalculationActivityIntegrationTest.cs
===================================================================
diff -u -rce5d60b8a5c520faec45cce64de6957dce747449 -rdf13dff5aedb149d7b566bed9dda68fe9e3a8e02
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Integration.Test/ClosingStructuresCalculationActivityIntegrationTest.cs (.../ClosingStructuresCalculationActivityIntegrationTest.cs) (revision ce5d60b8a5c520faec45cce64de6957dce747449)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Integration.Test/ClosingStructuresCalculationActivityIntegrationTest.cs (.../ClosingStructuresCalculationActivityIntegrationTest.cs) (revision df13dff5aedb149d7b566bed9dda68fe9e3a8e02)
@@ -207,7 +207,7 @@
{
InputParameters =
{
- HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001),
+ HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001)
}
};
@@ -261,7 +261,7 @@
{
InputParameters =
{
- HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001),
+ HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001)
}
};
Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Service.Test/ClosingStructuresCalculationServiceTest.cs
===================================================================
diff -u -rce5d60b8a5c520faec45cce64de6957dce747449 -rdf13dff5aedb149d7b566bed9dda68fe9e3a8e02
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Service.Test/ClosingStructuresCalculationServiceTest.cs (.../ClosingStructuresCalculationServiceTest.cs) (revision ce5d60b8a5c520faec45cce64de6957dce747449)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Service.Test/ClosingStructuresCalculationServiceTest.cs (.../ClosingStructuresCalculationServiceTest.cs) (revision df13dff5aedb149d7b566bed9dda68fe9e3a8e02)
@@ -944,14 +944,14 @@
public void Calculate_CalculationFailedWithExceptionAndLastErrorPresent_LogErrorAndThrowException()
{
// Setup
- var closingStructuresFailureMechanism = new ClosingStructuresFailureMechanism();
+ var failureMechanism = new ClosingStructuresFailureMechanism();
var mockRepository = new MockRepository();
- IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(closingStructuresFailureMechanism,
+ IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism,
mockRepository);
mockRepository.ReplayAll();
- closingStructuresFailureMechanism.AddSection(new FailureMechanismSection("test section", new[]
+ failureMechanism.AddSection(new FailureMechanismSection("test section", new[]
{
new Point2D(0, 0),
new Point2D(1, 1)
@@ -980,7 +980,7 @@
{
new ClosingStructuresCalculationService().Calculate(calculation,
assessmentSectionStub,
- closingStructuresFailureMechanism,
+ failureMechanism,
testDataPath);
}
catch (HydraRingFileParserException)
@@ -1006,14 +1006,14 @@
public void Calculate_CalculationFailedWithExceptionAndNoLastErrorPresent_LogErrorAndThrowException()
{
// Setup
- var closingStructuresFailureMechanism = new ClosingStructuresFailureMechanism();
+ var failureMechanism = new ClosingStructuresFailureMechanism();
var mockRepository = new MockRepository();
- IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(closingStructuresFailureMechanism,
+ IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism,
mockRepository);
mockRepository.ReplayAll();
- closingStructuresFailureMechanism.AddSection(new FailureMechanismSection("test section", new[]
+ failureMechanism.AddSection(new FailureMechanismSection("test section", new[]
{
new Point2D(0, 0),
new Point2D(1, 1)
@@ -1041,7 +1041,7 @@
{
new ClosingStructuresCalculationService().Calculate(calculation,
assessmentSectionStub,
- closingStructuresFailureMechanism,
+ failureMechanism,
testDataPath);
}
catch (HydraRingFileParserException)
@@ -1067,14 +1067,14 @@
public void Calculate_CalculationFailedWithoutExceptionAndWithLastErrorPresent_LogErrorAndThrowException()
{
// Setup
- var closingStructuresFailureMechanism = new ClosingStructuresFailureMechanism();
+ var failureMechanism = new ClosingStructuresFailureMechanism();
var mockRepository = new MockRepository();
- IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(closingStructuresFailureMechanism,
+ IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism,
mockRepository);
mockRepository.ReplayAll();
- closingStructuresFailureMechanism.AddSection(new FailureMechanismSection("test section", new[]
+ failureMechanism.AddSection(new FailureMechanismSection("test section", new[]
{
new Point2D(0, 0),
new Point2D(1, 1)
@@ -1104,7 +1104,7 @@
{
new ClosingStructuresCalculationService().Calculate(calculation,
assessmentSectionStub,
- closingStructuresFailureMechanism,
+ failureMechanism,
testDataPath);
}
catch (HydraRingFileParserException e)
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/HeightStructuresCalculationActivityIntegrationTest.cs
===================================================================
diff -u -r0fc840682ffcce4fc1074e7d6687e90cab58bd2b -rdf13dff5aedb149d7b566bed9dda68fe9e3a8e02
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/HeightStructuresCalculationActivityIntegrationTest.cs (.../HeightStructuresCalculationActivityIntegrationTest.cs) (revision 0fc840682ffcce4fc1074e7d6687e90cab58bd2b)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/HeightStructuresCalculationActivityIntegrationTest.cs (.../HeightStructuresCalculationActivityIntegrationTest.cs) (revision df13dff5aedb149d7b566bed9dda68fe9e3a8e02)
@@ -262,7 +262,7 @@
{
InputParameters =
{
- HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001),
+ HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001)
}
};
@@ -322,8 +322,7 @@
{
InputParameters =
{
- HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001),
- Structure = new TestHeightStructure()
+ HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001)
}
};
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Calculator/IStructuresStabilityPointCalculator.cs
===================================================================
diff -u -rbd73023d5f8926a411da214fb5ce522056a0e30a -rdf13dff5aedb149d7b566bed9dda68fe9e3a8e02
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Calculator/IStructuresStabilityPointCalculator.cs (.../IStructuresStabilityPointCalculator.cs) (revision bd73023d5f8926a411da214fb5ce522056a0e30a)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Calculator/IStructuresStabilityPointCalculator.cs (.../IStructuresStabilityPointCalculator.cs) (revision df13dff5aedb149d7b566bed9dda68fe9e3a8e02)
@@ -40,6 +40,11 @@
string OutputDirectory { get; }
///
+ /// Gets the content of the last error file generated during the Hydra-Ring calculation.
+ ///
+ string LastErrorContent { get; }
+
+ ///
/// Performs the actual calculation by running the Hydra-Ring executable.
///
/// The which contains all the necessary input
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/Calculator/TestHydraRingCalculatorFactory.cs
===================================================================
diff -u -r0fc840682ffcce4fc1074e7d6687e90cab58bd2b -rdf13dff5aedb149d7b566bed9dda68fe9e3a8e02
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/Calculator/TestHydraRingCalculatorFactory.cs (.../TestHydraRingCalculatorFactory.cs) (revision 0fc840682ffcce4fc1074e7d6687e90cab58bd2b)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/Calculator/TestHydraRingCalculatorFactory.cs (.../TestHydraRingCalculatorFactory.cs) (revision df13dff5aedb149d7b566bed9dda68fe9e3a8e02)
@@ -153,6 +153,7 @@
{
public double ExceedanceProbabilityBeta { get; set; }
public string OutputDirectory { get; set; }
+ public string LastErrorContent { get; set; }
}
public class TestHydraRingCalculator
Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/Properties/Resources.Designer.cs
===================================================================
diff -u -rbd73023d5f8926a411da214fb5ce522056a0e30a -rdf13dff5aedb149d7b566bed9dda68fe9e3a8e02
--- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision bd73023d5f8926a411da214fb5ce522056a0e30a)
+++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision df13dff5aedb149d7b566bed9dda68fe9e3a8e02)
@@ -82,16 +82,27 @@
}
///
- /// Looks up a localized string similar to De berekening voor kunstwerk puntconstructies '{0}' is niet gelukt..
+ /// Looks up a localized string similar to De berekening voor kunstwerk puntconstructies '{0}' is niet gelukt. Bekijk het foutrapport door op details te klikken.
+ ///{1}.
///
- internal static string StabilityPointStructuresCalculationService_Calculate_Error_in_stabilityPoint_structures_0_calculation {
+ internal static string StabilityPointStructuresCalculationService_Calculate_Error_in_stabilityPoint_structures_0_calculation_click_details_for_last_error_1 {
get {
return ResourceManager.GetString("StabilityPointStructuresCalculationService_Calculate_Error_in_stabilityPoint_stru" +
- "ctures_0_calculation", resourceCulture);
+ "ctures_0_calculation_click_details_for_last_error_1", resourceCulture);
}
}
///
+ /// Looks up a localized string similar to De berekening voor kunstwerk puntconstructies '{0}' is niet gelukt. Er is geen foutrapport beschikbaar..
+ ///
+ internal static string StabilityPointStructuresCalculationService_Calculate_Unexplained_error_in_stabilityPoint_structures_0_calculation {
+ get {
+ return ResourceManager.GetString("StabilityPointStructuresCalculationService_Calculate_Unexplained_error_in_stabili" +
+ "tyPoint_structures_0_calculation", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Puntconstructies berekening is uitgevoerd op de tijdelijke locatie: {0}. Gedetailleerde invoer en uitvoer kan in de bestanden op deze locatie worden gevonden..
///
internal static string StabilityPointStructuresCalculationService_CalculateCalculation_temporary_directory_can_be_found_on_location_0 {
Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/Properties/Resources.resx
===================================================================
diff -u -rbd73023d5f8926a411da214fb5ce522056a0e30a -rdf13dff5aedb149d7b566bed9dda68fe9e3a8e02
--- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/Properties/Resources.resx (.../Resources.resx) (revision bd73023d5f8926a411da214fb5ce522056a0e30a)
+++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/Properties/Resources.resx (.../Resources.resx) (revision df13dff5aedb149d7b566bed9dda68fe9e3a8e02)
@@ -120,7 +120,11 @@
Puntconstructies berekening is uitgevoerd op de tijdelijke locatie: {0}. Gedetailleerde invoer en uitvoer kan in de bestanden op deze locatie worden gevonden.
-
- De berekening voor kunstwerk puntconstructies '{0}' is niet gelukt.
+
+ De berekening voor kunstwerk puntconstructies '{0}' is niet gelukt. Bekijk het foutrapport door op details te klikken.
+{1}
+
+ De berekening voor kunstwerk puntconstructies '{0}' is niet gelukt. Er is geen foutrapport beschikbaar.
+
\ No newline at end of file
Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/StabilityPointStructuresCalculationService.cs
===================================================================
diff -u -rbd73023d5f8926a411da214fb5ce522056a0e30a -rdf13dff5aedb149d7b566bed9dda68fe9e3a8e02
--- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/StabilityPointStructuresCalculationService.cs (.../StabilityPointStructuresCalculationService.cs) (revision bd73023d5f8926a411da214fb5ce522056a0e30a)
+++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/StabilityPointStructuresCalculationService.cs (.../StabilityPointStructuresCalculationService.cs) (revision df13dff5aedb149d7b566bed9dda68fe9e3a8e02)
@@ -106,6 +106,7 @@
CalculationServiceHelper.LogCalculationBeginTime(calculationName);
+ var exceptionThrown = false;
try
{
calculator.Calculate(input);
@@ -122,14 +123,40 @@
{
if (!canceled)
{
- log.ErrorFormat(Resources.StabilityPointStructuresCalculationService_Calculate_Error_in_stabilityPoint_structures_0_calculation, calculationName);
+ var lastErrorContent = calculator.LastErrorContent;
+ if (string.IsNullOrEmpty(lastErrorContent))
+ {
+ log.ErrorFormat(Resources.StabilityPointStructuresCalculationService_Calculate_Unexplained_error_in_stabilityPoint_structures_0_calculation,
+ calculationName);
+ }
+ else
+ {
+ log.ErrorFormat(Resources.StabilityPointStructuresCalculationService_Calculate_Error_in_stabilityPoint_structures_0_calculation_click_details_for_last_error_1,
+ calculationName, lastErrorContent);
+ }
+
+ exceptionThrown = true;
throw;
}
}
finally
{
- log.InfoFormat(Resources.StabilityPointStructuresCalculationService_CalculateCalculation_temporary_directory_can_be_found_on_location_0, calculator.OutputDirectory);
- CalculationServiceHelper.LogCalculationEndTime(calculationName);
+ try
+ {
+ var lastErrorContent = calculator.LastErrorContent;
+ if (!exceptionThrown && !string.IsNullOrEmpty(lastErrorContent))
+ {
+ log.ErrorFormat(Resources.StabilityPointStructuresCalculationService_Calculate_Error_in_stabilityPoint_structures_0_calculation_click_details_for_last_error_1,
+ calculationName, lastErrorContent);
+
+ throw new HydraRingFileParserException(lastErrorContent);
+ }
+ }
+ finally
+ {
+ log.InfoFormat(Resources.StabilityPointStructuresCalculationService_CalculateCalculation_temporary_directory_can_be_found_on_location_0, calculator.OutputDirectory);
+ CalculationServiceHelper.LogCalculationEndTime(calculationName);
+ }
}
}
Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs
===================================================================
diff -u -r379d603ad7570ee56a65fecc920e56ca24279065 -rdf13dff5aedb149d7b566bed9dda68fe9e3a8e02
--- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 379d603ad7570ee56a65fecc920e56ca24279065)
+++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision df13dff5aedb149d7b566bed9dda68fe9e3a8e02)
@@ -780,13 +780,15 @@
StringAssert.StartsWith("Validatie van 'A' gestart om: ", messageList[0]);
StringAssert.StartsWith("Validatie van 'A' beëindigd om: ", messageList[1]);
StringAssert.StartsWith("Berekening van 'A' gestart om: ", messageList[2]);
- Assert.AreEqual("De berekening voor kunstwerk puntconstructies 'A' is niet gelukt.", messageList[3]);
+ StringAssert.StartsWith("De berekening voor kunstwerk puntconstructies 'A' is niet gelukt. Bekijk het foutrapport door op details te klikken.",
+ messageList[3]);
StringAssert.StartsWith("Puntconstructies berekening is uitgevoerd op de tijdelijke locatie:", messageList[4]);
StringAssert.StartsWith("Berekening van 'A' beëindigd om: ", messageList[5]);
StringAssert.StartsWith("Validatie van 'B' gestart om: ", messageList[6]);
StringAssert.StartsWith("Validatie van 'B' beëindigd om: ", messageList[7]);
StringAssert.StartsWith("Berekening van 'B' gestart om: ", messageList[8]);
- Assert.AreEqual("De berekening voor kunstwerk puntconstructies 'B' is niet gelukt.", messageList[9]);
+ StringAssert.StartsWith("De berekening voor kunstwerk puntconstructies 'B' is niet gelukt. Bekijk het foutrapport door op details te klikken.",
+ messageList[9]);
StringAssert.StartsWith("Puntconstructies berekening is uitgevoerd op de tijdelijke locatie:", messageList[10]);
StringAssert.StartsWith("Berekening van 'B' beëindigd om: ", messageList[11]);
Assert.AreEqual("Uitvoeren van 'A' is mislukt.", messageList[12]);
Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs
===================================================================
diff -u -r379d603ad7570ee56a65fecc920e56ca24279065 -rdf13dff5aedb149d7b566bed9dda68fe9e3a8e02
--- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 379d603ad7570ee56a65fecc920e56ca24279065)
+++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision df13dff5aedb149d7b566bed9dda68fe9e3a8e02)
@@ -687,13 +687,15 @@
StringAssert.StartsWith("Validatie van 'A' gestart om: ", messageList[0]);
StringAssert.StartsWith("Validatie van 'A' beëindigd om: ", messageList[1]);
StringAssert.StartsWith("Berekening van 'A' gestart om: ", messageList[2]);
- Assert.AreEqual("De berekening voor kunstwerk puntconstructies 'A' is niet gelukt.", messageList[3]);
+ StringAssert.StartsWith("De berekening voor kunstwerk puntconstructies 'A' is niet gelukt. Bekijk het foutrapport door op details te klikken.",
+ messageList[3]);
StringAssert.StartsWith("Puntconstructies berekening is uitgevoerd op de tijdelijke locatie:", messageList[4]);
StringAssert.StartsWith("Berekening van 'A' beëindigd om: ", messageList[5]);
StringAssert.StartsWith("Validatie van 'B' gestart om: ", messageList[6]);
StringAssert.StartsWith("Validatie van 'B' beëindigd om: ", messageList[7]);
StringAssert.StartsWith("Berekening van 'B' gestart om: ", messageList[8]);
- Assert.AreEqual("De berekening voor kunstwerk puntconstructies 'B' is niet gelukt.", messageList[9]);
+ StringAssert.StartsWith("De berekening voor kunstwerk puntconstructies 'B' is niet gelukt. Bekijk het foutrapport door op details te klikken.",
+ messageList[9]);
StringAssert.StartsWith("Puntconstructies berekening is uitgevoerd op de tijdelijke locatie:", messageList[10]);
StringAssert.StartsWith("Berekening van 'B' beëindigd om: ", messageList[11]);
Assert.AreEqual("Uitvoeren van 'A' is mislukt.", messageList[12]);
Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Integration.Test/StabilityPointStructuresCalculationActivityIntegrationTest.cs
===================================================================
diff -u -rdb80505bcfa73bd0d51e41d82ec4ab9c37c3ecbd -rdf13dff5aedb149d7b566bed9dda68fe9e3a8e02
--- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Integration.Test/StabilityPointStructuresCalculationActivityIntegrationTest.cs (.../StabilityPointStructuresCalculationActivityIntegrationTest.cs) (revision db80505bcfa73bd0d51e41d82ec4ab9c37c3ecbd)
+++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Integration.Test/StabilityPointStructuresCalculationActivityIntegrationTest.cs (.../StabilityPointStructuresCalculationActivityIntegrationTest.cs) (revision df13dff5aedb149d7b566bed9dda68fe9e3a8e02)
@@ -32,6 +32,7 @@
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Structures;
using Ringtoets.Common.IO.FileImporters;
+using Ringtoets.HydraRing.Calculation.Calculator.Factory;
using Ringtoets.HydraRing.Calculation.TestUtil.Calculator;
using Ringtoets.HydraRing.Data;
using Ringtoets.Integration.Data;
@@ -186,6 +187,117 @@
}
[Test]
+ public void Run_UnexplainedErrorInCalculation_PerformValidationAndCalculationAndLogStartAndEndAndError()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+
+ string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite");
+
+ using (var importer = new HydraulicBoundaryDatabaseImporter())
+ {
+ importer.Import(assessmentSection, validFilePath);
+ }
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ failureMechanism.AddSection(new FailureMechanismSection("test section", new[]
+ {
+ new Point2D(0, 0),
+ new Point2D(1, 1)
+ }));
+
+ var calculation = new TestStabilityPointStructuresCalculation()
+ {
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001),
+ LoadSchematizationType = LoadSchematizationType.Linear
+ }
+ };
+
+ var activity = new StabilityPointStructuresCalculationActivity(calculation, testDataPath, failureMechanism, assessmentSection);
+ using (new HydraRingCalculatorFactoryConfig())
+ {
+ var calculator = ((TestHydraRingCalculatorFactory)HydraRingCalculatorFactory.Instance).StructuresStabilityPointCalculator;
+ calculator.EndInFailure = true;
+
+ // Call
+ Action call = () => activity.Run();
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ var msgs = messages.ToArray();
+ Assert.AreEqual(6, msgs.Length);
+ StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]);
+ StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[1]);
+ StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[2]);
+ StringAssert.StartsWith(string.Format("De berekening voor kunstwerk puntconstructies '{0}' is niet gelukt. Er is geen foutrapport beschikbaar.",
+ calculation.Name), msgs[3]);
+ StringAssert.StartsWith("Puntconstructies berekening is uitgevoerd op de tijdelijke locatie:", msgs[4]);
+ StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[5]);
+ });
+ Assert.AreEqual(ActivityState.Failed, activity.State);
+ }
+ }
+
+ [Test]
+ public void Run_ErrorInCalculation_PerformValidationAndCalculationAndLogStartAndEndAndError()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+
+ string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite");
+
+ using (var importer = new HydraulicBoundaryDatabaseImporter())
+ {
+ importer.Import(assessmentSection, validFilePath);
+ }
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ failureMechanism.AddSection(new FailureMechanismSection("test section", new[]
+ {
+ new Point2D(0, 0),
+ new Point2D(1, 1)
+ }));
+
+ var calculation = new TestStabilityPointStructuresCalculation()
+ {
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001),
+ LoadSchematizationType = LoadSchematizationType.Linear
+ }
+ };
+
+ var activity = new StabilityPointStructuresCalculationActivity(calculation, testDataPath, failureMechanism, assessmentSection);
+ using (new HydraRingCalculatorFactoryConfig())
+ {
+ var calculator = ((TestHydraRingCalculatorFactory)HydraRingCalculatorFactory.Instance).StructuresStabilityPointCalculator;
+ calculator.EndInFailure = false;
+ calculator.LastErrorContent = "An error occured";
+
+ // Call
+ Action call = () => activity.Run();
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ var msgs = messages.ToArray();
+ Assert.AreEqual(6, msgs.Length);
+ StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]);
+ StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[1]);
+ StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[2]);
+ StringAssert.StartsWith(string.Format("De berekening voor kunstwerk puntconstructies '{0}' is niet gelukt. Bekijk het foutrapport door op details te klikken.",
+ calculation.Name), msgs[3]);
+ StringAssert.StartsWith("Puntconstructies berekening is uitgevoerd op de tijdelijke locatie:", msgs[4]);
+ StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[5]);
+ });
+ Assert.AreEqual(ActivityState.Failed, activity.State);
+ }
+ }
+
+ [Test]
public void Finish_ValidCalculationAndRan_SetsOutputAndNotifyObserversOfCalculation()
{
// Setup
Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Service.Test/StabilityPointStructuresCalculationServiceTest.cs
===================================================================
diff -u -rdb80505bcfa73bd0d51e41d82ec4ab9c37c3ecbd -rdf13dff5aedb149d7b566bed9dda68fe9e3a8e02
--- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Service.Test/StabilityPointStructuresCalculationServiceTest.cs (.../StabilityPointStructuresCalculationServiceTest.cs) (revision db80505bcfa73bd0d51e41d82ec4ab9c37c3ecbd)
+++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Service.Test/StabilityPointStructuresCalculationServiceTest.cs (.../StabilityPointStructuresCalculationServiceTest.cs) (revision df13dff5aedb149d7b566bed9dda68fe9e3a8e02)
@@ -517,7 +517,7 @@
}
};
- SetInvalidInputParameters(calculation.InputParameters, (RoundedDouble)value);
+ SetInvalidInputParameters(calculation.InputParameters, (RoundedDouble) value);
bool isValid = false;
@@ -1463,6 +1463,198 @@
}
}
+ [Test]
+ public void Calculate_CalculationFailedWithExceptionAndLastErrorPresent_LogErrorAndThrowException()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mockRepository = new MockRepository();
+ IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism,
+ mockRepository);
+ mockRepository.ReplayAll();
+
+ failureMechanism.AddSection(new FailureMechanismSection("test section", new[]
+ {
+ new Point2D(0, 0),
+ new Point2D(1, 1)
+ }));
+
+ var calculation = new TestStabilityPointStructuresCalculation
+ {
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = assessmentSectionStub.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001),
+ LoadSchematizationType = LoadSchematizationType.Linear
+ }
+ };
+
+ using (new HydraRingCalculatorFactoryConfig())
+ {
+ var calculator = ((TestHydraRingCalculatorFactory) HydraRingCalculatorFactory.Instance).StructuresStabilityPointCalculator;
+ calculator.LastErrorContent = "An error occured";
+ calculator.EndInFailure = true;
+
+ var exceptionThrown = false;
+
+ // Call
+ Action call = () =>
+ {
+ try
+ {
+ new StabilityPointStructuresCalculationService().Calculate(calculation,
+ assessmentSectionStub,
+ failureMechanism,
+ testDataPath);
+ }
+ catch (HydraRingFileParserException)
+ {
+ exceptionThrown = true;
+ }
+ };
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ var msgs = messages.ToArray();
+ Assert.AreEqual(4, msgs.Length);
+ StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]);
+ StringAssert.StartsWith(string.Format("De berekening voor kunstwerk puntconstructies '{0}' is niet gelukt. Bekijk het foutrapport door op details te klikken.", calculation.Name), msgs[1]);
+ StringAssert.StartsWith("Puntconstructies berekening is uitgevoerd op de tijdelijke locatie:", msgs[2]);
+ StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[3]);
+ });
+ Assert.IsTrue(exceptionThrown);
+ }
+ }
+
+ [Test]
+ public void Calculate_CalculationFailedWithExceptionAndNoLastErrorPresent_LogErrorAndThrowException()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mockRepository = new MockRepository();
+ IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism,
+ mockRepository);
+ mockRepository.ReplayAll();
+
+ failureMechanism.AddSection(new FailureMechanismSection("test section", new[]
+ {
+ new Point2D(0, 0),
+ new Point2D(1, 1)
+ }));
+
+ var calculation = new TestStabilityPointStructuresCalculation
+ {
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = assessmentSectionStub.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001),
+ LoadSchematizationType = LoadSchematizationType.Linear
+ }
+ };
+
+ using (new HydraRingCalculatorFactoryConfig())
+ {
+ var calculator = ((TestHydraRingCalculatorFactory) HydraRingCalculatorFactory.Instance).StructuresStabilityPointCalculator;
+ calculator.EndInFailure = true;
+
+ var exceptionThrown = false;
+
+ // Call
+ Action call = () =>
+ {
+ try
+ {
+ new StabilityPointStructuresCalculationService().Calculate(calculation,
+ assessmentSectionStub,
+ failureMechanism,
+ testDataPath);
+ }
+ catch (HydraRingFileParserException)
+ {
+ exceptionThrown = true;
+ }
+ };
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ var msgs = messages.ToArray();
+ Assert.AreEqual(4, msgs.Length);
+ StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]);
+ StringAssert.StartsWith(string.Format("De berekening voor kunstwerk puntconstructies '{0}' is niet gelukt. Er is geen foutrapport beschikbaar.", calculation.Name), msgs[1]);
+ StringAssert.StartsWith("Puntconstructies berekening is uitgevoerd op de tijdelijke locatie:", msgs[2]);
+ StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[3]);
+ });
+ Assert.IsTrue(exceptionThrown);
+ }
+ }
+
+ [Test]
+ public void Calculate_CalculationFailedWithoutExceptionAndWithLastErrorPresent_LogErrorAndThrowException()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mockRepository = new MockRepository();
+ IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism,
+ mockRepository);
+ mockRepository.ReplayAll();
+
+ failureMechanism.AddSection(new FailureMechanismSection("test section", new[]
+ {
+ new Point2D(0, 0),
+ new Point2D(1, 1)
+ }));
+
+ var calculation = new TestStabilityPointStructuresCalculation
+ {
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = assessmentSectionStub.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001),
+ LoadSchematizationType = LoadSchematizationType.Linear
+ }
+ };
+
+ using (new HydraRingCalculatorFactoryConfig())
+ {
+ var calculator = ((TestHydraRingCalculatorFactory) HydraRingCalculatorFactory.Instance).StructuresStabilityPointCalculator;
+ calculator.EndInFailure = false;
+ calculator.LastErrorContent = "An error occured";
+
+ var exceptionThrown = false;
+ var exceptionMessage = string.Empty;
+
+ // Call
+ Action call = () =>
+ {
+ try
+ {
+ new StabilityPointStructuresCalculationService().Calculate(calculation,
+ assessmentSectionStub,
+ failureMechanism,
+ testDataPath);
+ }
+ catch (HydraRingFileParserException e)
+ {
+ exceptionThrown = true;
+ exceptionMessage = e.Message;
+ }
+ };
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ var msgs = messages.ToArray();
+ Assert.AreEqual(4, msgs.Length);
+ StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]);
+ StringAssert.StartsWith(string.Format("De berekening voor kunstwerk puntconstructies '{0}' is niet gelukt. Bekijk het foutrapport door op details te klikken.",
+ calculation.Name), msgs[1]);
+ StringAssert.StartsWith("Puntconstructies berekening is uitgevoerd op de tijdelijke locatie:", msgs[2]);
+ StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[3]);
+ });
+ Assert.IsTrue(exceptionThrown);
+ Assert.AreEqual(calculator.LastErrorContent, exceptionMessage);
+ }
+ }
+
///
/// Sets all input parameters of to invalid values.
///