Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/Configurations/ClosingStructuresCalculationConfigurationImporterTest.cs =================================================================== diff -u -r36b8629b18443a58866edc869420795588eaf168 -rfe7c27dc926b4087fd6ed9551655d0571c8018c9 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/Configurations/ClosingStructuresCalculationConfigurationImporterTest.cs (.../ClosingStructuresCalculationConfigurationImporterTest.cs) (revision 36b8629b18443a58866edc869420795588eaf168) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.IO.Test/Configurations/ClosingStructuresCalculationConfigurationImporterTest.cs (.../ClosingStructuresCalculationConfigurationImporterTest.cs) (revision fe7c27dc926b4087fd6ed9551655d0571c8018c9) @@ -27,15 +27,15 @@ using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; +using Ringtoets.ClosingStructures.Data; +using Ringtoets.ClosingStructures.Data.TestUtil; +using Ringtoets.ClosingStructures.IO.Configurations; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Data.TestUtil; -using Ringtoets.Common.IO.FileImporters; -using Ringtoets.ClosingStructures.Data; -using Ringtoets.ClosingStructures.Data.TestUtil; -using Ringtoets.ClosingStructures.IO.Configurations; +using Ringtoets.Common.IO.Configurations.Import; namespace Ringtoets.ClosingStructures.IO.Test.Configurations { @@ -49,10 +49,10 @@ { // Call var importer = new ClosingStructuresCalculationConfigurationImporter("", - new CalculationGroup(), - Enumerable.Empty(), - Enumerable.Empty(), - Enumerable.Empty()); + new CalculationGroup(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty()); // Assert Assert.IsInstanceOf>(importer); @@ -63,10 +63,10 @@ { // Call TestDelegate test = () => new ClosingStructuresCalculationConfigurationImporter("", - new CalculationGroup(), - null, - Enumerable.Empty(), - Enumerable.Empty()); + new CalculationGroup(), + null, + Enumerable.Empty(), + Enumerable.Empty()); // Assert var exception = Assert.Throws(test); @@ -78,10 +78,10 @@ { // Call TestDelegate test = () => new ClosingStructuresCalculationConfigurationImporter("", - new CalculationGroup(), - Enumerable.Empty(), - null, - Enumerable.Empty()); + new CalculationGroup(), + Enumerable.Empty(), + null, + Enumerable.Empty()); // Assert var exception = Assert.Throws(test); @@ -93,10 +93,10 @@ { // Call TestDelegate test = () => new ClosingStructuresCalculationConfigurationImporter("", - new CalculationGroup(), - Enumerable.Empty(), - Enumerable.Empty(), - null); + new CalculationGroup(), + Enumerable.Empty(), + Enumerable.Empty(), + null); // Assert var exception = Assert.Throws(test); @@ -200,16 +200,16 @@ var foreshoreProfile = new TestForeshoreProfile("profiel 1"); var importer = new ClosingStructuresCalculationConfigurationImporter(filePath, - calculationGroup, - Enumerable.Empty(), - new ForeshoreProfile[] - { - foreshoreProfile - }, - new ClosingStructure[] - { - structure - }); + calculationGroup, + Enumerable.Empty(), + new ForeshoreProfile[] + { + foreshoreProfile + }, + new ClosingStructure[] + { + structure + }); var successful = false; // Call @@ -222,36 +222,6 @@ CollectionAssert.IsEmpty(calculationGroup.Children); } - [TestCase("validConfigurationUnknownForeshoreProfile.xml", - "Het voorlandprofiel 'unknown' bestaat niet.")] - [TestCase("validConfigurationUnknownHydraulicBoundaryLocation.xml", - "De locatie met hydraulische randvoorwaarden 'unknown' bestaat niet.")] - [TestCase("validConfigurationUnknownStructure.xml", - "Het kunstwerk 'unknown' bestaat niet.")] - public void Import_ValidConfigurationUnknownData_LogMessageAndContinueImport(string file, string expectedErrorMessage) - { - // Setup - string filePath = Path.Combine(importerPath, file); - - var calculationGroup = new CalculationGroup(); - - var importer = new ClosingStructuresCalculationConfigurationImporter(filePath, - calculationGroup, - Enumerable.Empty(), - Enumerable.Empty(), - Enumerable.Empty()); - var successful = false; - - // Call - Action call = () => successful = importer.Import(); - - // Assert - string expectedMessage = $"{expectedErrorMessage} Berekening 'Berekening 1' is overgeslagen."; - TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 1); - Assert.IsTrue(successful); - CollectionAssert.IsEmpty(calculationGroup.Children); - } - [Test] public void Import_UseForeshoreButForeshoreProfileWithoutGeometry_LogMessageAndContinueImport() { @@ -292,7 +262,7 @@ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("Locatie1"); var foreshoreProfile = new TestForeshoreProfile("profiel1", new List { - new Point2D(0,3) + new Point2D(0, 3) }); var structure = new TestClosingStructure("kunstwerk1"); var importer = new ClosingStructuresCalculationConfigurationImporter( @@ -310,9 +280,9 @@ { structure }); - + // Call - var successful = importer.Import(); + bool successful = importer.Import(); // Assert Assert.IsTrue(successful); @@ -377,21 +347,21 @@ Mean = (RoundedDouble) 4.3, StandardDeviation = (RoundedDouble) 0.2 }, - AreaFlowApertures = + AreaFlowApertures = { Mean = (RoundedDouble) 80.5, StandardDeviation = (RoundedDouble) 1 }, - DrainCoefficient = + DrainCoefficient = { Mean = (RoundedDouble) 1.1, }, - InsideWaterLevel = + InsideWaterLevel = { Mean = (RoundedDouble) 0.5, StandardDeviation = (RoundedDouble) 0.1 }, - ThresholdHeightOpenWeir = + ThresholdHeightOpenWeir = { Mean = (RoundedDouble) 1.2, StandardDeviation = (RoundedDouble) 0.1 @@ -400,7 +370,7 @@ }; Assert.AreEqual(1, calculationGroup.Children.Count); - AssertCalculation(expectedCalculation, (StructuresCalculation)calculationGroup.Children[0]); + AssertCalculation(expectedCalculation, (StructuresCalculation) calculationGroup.Children[0]); } [Test] @@ -477,14 +447,14 @@ } } }; - + // Call - var successful = importer.Import(); + bool successful = importer.Import(); // Assert Assert.IsTrue(successful); Assert.AreEqual(1, calculationGroup.Children.Count); - AssertCalculation(expectedCalculation, (StructuresCalculation)calculationGroup.Children[0]); + AssertCalculation(expectedCalculation, (StructuresCalculation) calculationGroup.Children[0]); } [Test] @@ -549,14 +519,14 @@ } } }; - + // Call - var successful = importer.Import(); + bool successful = importer.Import(); // Assert Assert.IsTrue(successful); Assert.AreEqual(1, calculationGroup.Children.Count); - AssertCalculation(expectedCalculation, (StructuresCalculation)calculationGroup.Children[0]); + AssertCalculation(expectedCalculation, (StructuresCalculation) calculationGroup.Children[0]); } [Test] @@ -585,16 +555,46 @@ { Name = "Berekening 1" }; - + // Call - var successful = importer.Import(); + bool successful = importer.Import(); // Assert Assert.IsTrue(successful); Assert.AreEqual(1, calculationGroup.Children.Count); - AssertCalculation(expectedCalculation, (StructuresCalculation)calculationGroup.Children[0]); + AssertCalculation(expectedCalculation, (StructuresCalculation) calculationGroup.Children[0]); } + [TestCase("validConfigurationUnknownForeshoreProfile.xml", + "Het voorlandprofiel 'unknown' bestaat niet.")] + [TestCase("validConfigurationUnknownHydraulicBoundaryLocation.xml", + "De locatie met hydraulische randvoorwaarden 'unknown' bestaat niet.")] + [TestCase("validConfigurationUnknownStructure.xml", + "Het kunstwerk 'unknown' bestaat niet.")] + public void Import_ValidConfigurationUnknownData_LogMessageAndContinueImport(string file, string expectedErrorMessage) + { + // Setup + string filePath = Path.Combine(importerPath, file); + + var calculationGroup = new CalculationGroup(); + + var importer = new ClosingStructuresCalculationConfigurationImporter(filePath, + calculationGroup, + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty()); + var successful = false; + + // Call + Action call = () => successful = importer.Import(); + + // Assert + string expectedMessage = $"{expectedErrorMessage} Berekening 'Berekening 1' is overgeslagen."; + TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 1); + Assert.IsTrue(successful); + CollectionAssert.IsEmpty(calculationGroup.Children); + } + private static void AssertCalculation(StructuresCalculation expectedCalculation, StructuresCalculation actualCalculation) { Assert.AreEqual(expectedCalculation.Name, actualCalculation.Name);