Index: Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.IO/Configurations/StabilityPointStructuresCalculationConfigurationImporter.cs =================================================================== diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -ra51d17f846f40d0336ed5252799cb32bf55df9d3 --- Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.IO/Configurations/StabilityPointStructuresCalculationConfigurationImporter.cs (.../StabilityPointStructuresCalculationConfigurationImporter.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea) +++ Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.IO/Configurations/StabilityPointStructuresCalculationConfigurationImporter.cs (.../StabilityPointStructuresCalculationConfigurationImporter.cs) (revision a51d17f846f40d0336ed5252799cb32bf55df9d3) @@ -114,7 +114,7 @@ protected override ICalculation ParseReadCalculation(StabilityPointStructuresCalculationConfiguration readCalculation) { - var calculation = new StructuresCalculation + var calculation = new StructuresCalculationScenario { Name = readCalculation.Name }; Index: Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.IO.Test/Configurations/StabilityPointStructuresCalculationConfigurationImporterTest.cs =================================================================== diff -u -r4a91111c1fda2c629fef0f552a2b33d9dbb5df92 -ra51d17f846f40d0336ed5252799cb32bf55df9d3 --- Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.IO.Test/Configurations/StabilityPointStructuresCalculationConfigurationImporterTest.cs (.../StabilityPointStructuresCalculationConfigurationImporterTest.cs) (revision 4a91111c1fda2c629fef0f552a2b33d9dbb5df92) +++ Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.IO.Test/Configurations/StabilityPointStructuresCalculationConfigurationImporterTest.cs (.../StabilityPointStructuresCalculationConfigurationImporterTest.cs) (revision a51d17f846f40d0336ed5252799cb32bf55df9d3) @@ -490,63 +490,47 @@ public void Constructor_HydraulicBoundaryLocationsNull_ThrowArgumentNullException() { // Call - TestDelegate test = () => new StabilityPointStructuresCalculationConfigurationImporter("", - new CalculationGroup(), - null, - Enumerable.Empty(), - Enumerable.Empty(), - new StabilityPointStructuresFailureMechanism()); + void Call() => new StabilityPointStructuresCalculationConfigurationImporter("", new CalculationGroup(), null, Enumerable.Empty(), + Enumerable.Empty(), new StabilityPointStructuresFailureMechanism()); // 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 StabilityPointStructuresCalculationConfigurationImporter("", - new CalculationGroup(), - Enumerable.Empty(), - null, - Enumerable.Empty(), - new StabilityPointStructuresFailureMechanism()); + void Call() => new StabilityPointStructuresCalculationConfigurationImporter("", new CalculationGroup(), Enumerable.Empty(), null, + Enumerable.Empty(), new StabilityPointStructuresFailureMechanism()); // 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 StabilityPointStructuresCalculationConfigurationImporter("", - new CalculationGroup(), - Enumerable.Empty(), - Enumerable.Empty(), - null, - new StabilityPointStructuresFailureMechanism()); + void Call() => new StabilityPointStructuresCalculationConfigurationImporter("", new CalculationGroup(), Enumerable.Empty(), Enumerable.Empty(), + null, new StabilityPointStructuresFailureMechanism()); // 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 StabilityPointStructuresCalculationConfigurationImporter("", - new CalculationGroup(), - Enumerable.Empty(), - Enumerable.Empty(), - Enumerable.Empty(), - null); + void Call() => new StabilityPointStructuresCalculationConfigurationImporter("", 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); } @@ -578,11 +562,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); } @@ -609,12 +593,12 @@ 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); } @@ -644,7 +628,7 @@ // Assert Assert.IsTrue(successful); - var expectedCalculation = new StructuresCalculation + var expectedCalculation = new StructuresCalculationScenario { Name = "Berekening 1", InputParameters = @@ -738,7 +722,7 @@ }; Assert.AreEqual(1, calculationGroup.Children.Count); - AssertCalculation(expectedCalculation, (StructuresCalculation) calculationGroup.Children[0]); + AssertCalculation(expectedCalculation, (StructuresCalculationScenario) calculationGroup.Children[0]); } [Test] @@ -766,7 +750,7 @@ // Assert Assert.IsTrue(successful); - var expectedCalculation = new StructuresCalculation + var expectedCalculation = new StructuresCalculationScenario { Name = "Berekening 1", InputParameters = @@ -848,7 +832,7 @@ }; Assert.AreEqual(1, calculationGroup.Children.Count); - AssertCalculation(expectedCalculation, (StructuresCalculation) calculationGroup.Children[0]); + AssertCalculation(expectedCalculation, (StructuresCalculationScenario) calculationGroup.Children[0]); } [Test] @@ -874,7 +858,7 @@ }, new StabilityPointStructuresFailureMechanism()); - var expectedCalculation = new StructuresCalculation + var expectedCalculation = new StructuresCalculationScenario { Name = "Berekening 1" }; @@ -885,7 +869,7 @@ // Assert Assert.IsTrue(successful); Assert.AreEqual(1, calculationGroup.Children.Count); - AssertCalculation(expectedCalculation, (StructuresCalculation) calculationGroup.Children[0]); + AssertCalculation(expectedCalculation, (StructuresCalculationScenario) calculationGroup.Children[0]); } [Test] @@ -928,7 +912,7 @@ // Assert 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 = @@ -1061,7 +1045,7 @@ }; Assert.AreEqual(1, calculationGroup.Children.Count); - AssertCalculation(expectedCalculation, (StructuresCalculation) calculationGroup.Children[0]); + AssertCalculation(expectedCalculation, (StructuresCalculationScenario) calculationGroup.Children[0]); } [Test] @@ -1143,14 +1127,14 @@ } [TestCase("validConfigurationUnknownForeshoreProfile.xml", - "Het voorlandprofiel met ID 'unknown' bestaat niet.", - TestName = "Import_UnknownData({0:80})")] + "Het voorlandprofiel met ID 'unknown' bestaat niet.", + TestName = "Import_UnknownData({0:80})")] [TestCase("validConfigurationUnknownHydraulicBoundaryLocation.xml", - "De hydraulische belastingenlocatie 'unknown' bestaat niet.", - TestName = "Import_UnknownData({0:80})")] + "De hydraulische belastingenlocatie 'unknown' bestaat niet.", + TestName = "Import_UnknownData({0:80})")] [TestCase("validConfigurationUnknownStructure.xml", - "Het kunstwerk met ID 'unknown' bestaat niet.", - TestName = "Import_UnknownData({0:80})")] + "Het kunstwerk met ID 'unknown' bestaat niet.", + TestName = "Import_UnknownData({0:80})")] public void Import_ValidConfigurationUnknownData_LogMessageAndContinueImport(string file, string expectedErrorMessage) { // Setup @@ -1176,10 +1160,12 @@ 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.AreEqual(expectedCalculation.InputParameters.BreakWater.Height, actualCalculation.InputParameters.BreakWater.Height); Assert.AreEqual(expectedCalculation.InputParameters.BreakWater.Type, actualCalculation.InputParameters.BreakWater.Type); Assert.AreEqual(expectedCalculation.InputParameters.EvaluationLevel, actualCalculation.InputParameters.EvaluationLevel);