Index: Riskeer/HeightStructures/src/Riskeer.HeightStructures.IO/Configurations/HeightStructuresCalculationConfigurationImporter.cs =================================================================== diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -r5c2c711a2bd1ba6ee466a362556cdab90f6fa379 --- Riskeer/HeightStructures/src/Riskeer.HeightStructures.IO/Configurations/HeightStructuresCalculationConfigurationImporter.cs (.../HeightStructuresCalculationConfigurationImporter.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea) +++ Riskeer/HeightStructures/src/Riskeer.HeightStructures.IO/Configurations/HeightStructuresCalculationConfigurationImporter.cs (.../HeightStructuresCalculationConfigurationImporter.cs) (revision 5c2c711a2bd1ba6ee466a362556cdab90f6fa379) @@ -109,7 +109,7 @@ protected override ICalculation ParseReadCalculation(HeightStructuresCalculationConfiguration readCalculation) { - var calculation = new StructuresCalculation + var calculation = new StructuresCalculationScenario { Name = readCalculation.Name }; Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.IO.Test/Configurations/HeightStructuresCalculationConfigurationImporterTest.cs =================================================================== diff -u -r4a91111c1fda2c629fef0f552a2b33d9dbb5df92 -r5c2c711a2bd1ba6ee466a362556cdab90f6fa379 --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.IO.Test/Configurations/HeightStructuresCalculationConfigurationImporterTest.cs (.../HeightStructuresCalculationConfigurationImporterTest.cs) (revision 4a91111c1fda2c629fef0f552a2b33d9dbb5df92) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.IO.Test/Configurations/HeightStructuresCalculationConfigurationImporterTest.cs (.../HeightStructuresCalculationConfigurationImporterTest.cs) (revision 5c2c711a2bd1ba6ee466a362556cdab90f6fa379) @@ -170,63 +170,51 @@ public void Constructor_HydraulicBoundaryLocationsNull_ThrowArgumentNullException() { // Call - TestDelegate test = () => new HeightStructuresCalculationConfigurationImporter("", - new CalculationGroup(), - null, - Enumerable.Empty(), - Enumerable.Empty(), - new HeightStructuresFailureMechanism()); + void Call() => new HeightStructuresCalculationConfigurationImporter( + "", new CalculationGroup(), null, Enumerable.Empty(), + Enumerable.Empty(), new HeightStructuresFailureMechanism()); // Assert - var exception = Assert.Throws(test); + var exception = Assert.Throws(Call); Assert.AreEqual("hydraulicBoundaryLocations", exception.ParamName); } [Test] public void Constructor_ForeshoreProfilesNull_ThrowArgumentNullException() { // Call - TestDelegate test = () => new HeightStructuresCalculationConfigurationImporter("", - new CalculationGroup(), - Enumerable.Empty(), - null, - Enumerable.Empty(), - new HeightStructuresFailureMechanism()); + void Call() => new HeightStructuresCalculationConfigurationImporter( + "", new CalculationGroup(), Enumerable.Empty(), null, + Enumerable.Empty(), new HeightStructuresFailureMechanism()); // Assert - var exception = Assert.Throws(test); + var exception = Assert.Throws(Call); Assert.AreEqual("foreshoreProfiles", exception.ParamName); } [Test] public void Constructor_StructuresNull_ThrowArgumentNullException() { // Call - TestDelegate test = () => new HeightStructuresCalculationConfigurationImporter("", - new CalculationGroup(), - Enumerable.Empty(), - Enumerable.Empty(), - null, - new HeightStructuresFailureMechanism()); + void Call() => new HeightStructuresCalculationConfigurationImporter( + "", new CalculationGroup(), Enumerable.Empty(), Enumerable.Empty(), + null, new HeightStructuresFailureMechanism()); // Assert - var exception = Assert.Throws(test); + var exception = Assert.Throws(Call); Assert.AreEqual("structures", exception.ParamName); } [Test] public void Constructor_FailureMechanismNull_ThrowArgumentNullException() { // Call - TestDelegate test = () => new HeightStructuresCalculationConfigurationImporter("", - new CalculationGroup(), - Enumerable.Empty(), - Enumerable.Empty(), - Enumerable.Empty(), - null); + void Call() => new HeightStructuresCalculationConfigurationImporter( + "", new CalculationGroup(), Enumerable.Empty(), + Enumerable.Empty(), Enumerable.Empty(), null); // Assert - var exception = Assert.Throws(test); + var exception = Assert.Throws(Call); Assert.AreEqual("failureMechanism", exception.ParamName); } @@ -257,11 +245,11 @@ var successful = false; // Call - Action call = () => successful = importer.Import(); + void Call() => successful = importer.Import(); // Assert string expectedMessage = $"{expectedErrorMessage} Berekening 'Berekening 1' is overgeslagen."; - TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 2); + TestHelper.AssertLogMessageWithLevelIsGenerated(Call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 2); Assert.IsTrue(successful); CollectionAssert.IsEmpty(calculationGroup.Children); } @@ -288,11 +276,11 @@ var successful = false; // Call - Action call = () => successful = importer.Import(); + void Call() => successful = importer.Import(); // Assert const string expectedMessage = "Het opgegeven voorlandprofiel 'Voorlandprofiel' heeft geen voorlandgeometrie en kan daarom niet gebruikt worden. Berekening 'Berekening 1' is overgeslagen."; - TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 2); + TestHelper.AssertLogMessageWithLevelIsGenerated(Call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 2); Assert.IsTrue(successful); CollectionAssert.IsEmpty(calculationGroup.Children); } @@ -329,13 +317,13 @@ // Call var successful = false; - Action call = () => successful = importer.Import(); + void Call() => successful = importer.Import(); // Assert - TestHelper.AssertLogMessageIsGenerated(call, $"Gegevens zijn geïmporteerd vanuit bestand '{filePath}'.", 1); + TestHelper.AssertLogMessageIsGenerated(Call, $"Gegevens zijn geïmporteerd vanuit bestand '{filePath}'.", 1); Assert.IsTrue(successful); - var expectedCalculation = new StructuresCalculation + var expectedCalculation = new StructuresCalculationScenario { Name = "Berekening 1", InputParameters = @@ -395,7 +383,7 @@ }; Assert.AreEqual(1, calculationGroup.Children.Count); - AssertCalculation(expectedCalculation, (StructuresCalculation) calculationGroup.Children[0]); + AssertCalculation(expectedCalculation, (StructuresCalculationScenario) calculationGroup.Children[0]); } [Test] @@ -417,7 +405,7 @@ }, new HeightStructuresFailureMechanism()); - var expectedCalculation = new StructuresCalculation + var expectedCalculation = new StructuresCalculationScenario { Name = "Berekening 1", InputParameters = @@ -464,7 +452,7 @@ // Assert Assert.IsTrue(successful); Assert.AreEqual(1, calculationGroup.Children.Count); - AssertCalculation(expectedCalculation, (StructuresCalculation) calculationGroup.Children[0]); + AssertCalculation(expectedCalculation, (StructuresCalculationScenario) calculationGroup.Children[0]); } [Test] @@ -486,7 +474,7 @@ }, new HeightStructuresFailureMechanism()); - var expectedCalculation = new StructuresCalculation + var expectedCalculation = new StructuresCalculationScenario { Name = "Berekening 1", InputParameters = @@ -525,7 +513,7 @@ // Assert Assert.IsTrue(successful); Assert.AreEqual(1, calculationGroup.Children.Count); - AssertCalculation(expectedCalculation, (StructuresCalculation) calculationGroup.Children[0]); + AssertCalculation(expectedCalculation, (StructuresCalculationScenario) calculationGroup.Children[0]); } [Test] @@ -551,7 +539,7 @@ }, new HeightStructuresFailureMechanism()); - var expectedCalculation = new StructuresCalculation + var expectedCalculation = new StructuresCalculationScenario { Name = "Berekening 1" }; @@ -562,7 +550,7 @@ // Assert Assert.IsTrue(successful); Assert.AreEqual(1, calculationGroup.Children.Count); - AssertCalculation(expectedCalculation, (StructuresCalculation) calculationGroup.Children[0]); + AssertCalculation(expectedCalculation, (StructuresCalculationScenario) calculationGroup.Children[0]); } [Test] @@ -614,11 +602,11 @@ } [TestCase("validConfigurationUnknownForeshoreProfile.xml", - "Het voorlandprofiel met ID 'unknown' bestaat niet.")] + "Het voorlandprofiel met ID 'unknown' bestaat niet.")] [TestCase("validConfigurationUnknownHydraulicBoundaryLocation.xml", - "De hydraulische belastingenlocatie 'unknown' bestaat niet.")] + "De hydraulische belastingenlocatie 'unknown' bestaat niet.")] [TestCase("validConfigurationUnknownStructure.xml", - "Het kunstwerk met ID 'unknown' bestaat niet.")] + "Het kunstwerk met ID 'unknown' bestaat niet.")] public void Import_ValidConfigurationUnknownData_LogMessageAndContinueImport(string file, string expectedErrorMessage) { // Setup @@ -635,18 +623,20 @@ var successful = false; // Call - Action call = () => successful = importer.Import(); + void Call() => successful = importer.Import(); // Assert string expectedMessage = $"{expectedErrorMessage} Berekening 'Berekening 1' is overgeslagen."; - TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 2); + TestHelper.AssertLogMessageWithLevelIsGenerated(Call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 2); Assert.IsTrue(successful); CollectionAssert.IsEmpty(calculationGroup.Children); } - private static void AssertCalculation(StructuresCalculation expectedCalculation, StructuresCalculation actualCalculation) + private static void AssertCalculation(StructuresCalculationScenario expectedCalculation, StructuresCalculationScenario actualCalculation) { Assert.AreEqual(expectedCalculation.Name, actualCalculation.Name); + Assert.AreEqual(expectedCalculation.IsRelevant, actualCalculation.IsRelevant); + Assert.AreEqual(expectedCalculation.Contribution, actualCalculation.Contribution); Assert.AreSame(expectedCalculation.InputParameters.HydraulicBoundaryLocation, actualCalculation.InputParameters.HydraulicBoundaryLocation); Assert.AreEqual(expectedCalculation.InputParameters.StructureNormalOrientation, actualCalculation.InputParameters.StructureNormalOrientation); Assert.AreSame(expectedCalculation.InputParameters.ForeshoreProfile, actualCalculation.InputParameters.ForeshoreProfile);