public void Import_EmptyConfigurations_DataAddedToModel(string file) { // Setup string filePath = Path.Combine(importerPath, file); var calculationGroup = new CalculationGroup(); var structure = new TestHeightStructure("kunstwerk1", "kunstwerk1"); var importer = new HeightStructuresCalculationConfigurationImporter( filePath, calculationGroup, Enumerable.Empty <HydraulicBoundaryLocation>(), Enumerable.Empty <ForeshoreProfile>(), new[] { structure }); var expectedCalculation = new StructuresCalculationScenario <HeightStructuresInput> { Name = "Berekening 1" }; // Call bool successful = importer.Import(); // Assert Assert.IsTrue(successful); Assert.AreEqual(1, calculationGroup.Children.Count); AssertCalculation(expectedCalculation, (StructuresCalculationScenario <HeightStructuresInput>)calculationGroup.Children[0]); }
public void Import_ScenarioWithRelevantSet_DataAddedToModel() { // Setup string filePath = Path.Combine(importerPath, "validConfigurationScenarioRelevantOnly.xml"); var calculationGroup = new CalculationGroup(); var importer = new HeightStructuresCalculationConfigurationImporter(filePath, calculationGroup, Enumerable.Empty <HydraulicBoundaryLocation>(), Enumerable.Empty <ForeshoreProfile>(), Enumerable.Empty <HeightStructure>()); // Call var successful = false; Action call = () => successful = importer.Import(); // Assert TestHelper.AssertLogMessageIsGenerated(call, $"Gegevens zijn geïmporteerd vanuit bestand '{filePath}'.", 1); Assert.IsTrue(successful); var expectedCalculation = new StructuresCalculationScenario <HeightStructuresInput> { Name = "Calculation", IsRelevant = false }; Assert.AreEqual(1, calculationGroup.Children.Count); AssertCalculation(expectedCalculation, (StructuresCalculationScenario <HeightStructuresInput>)calculationGroup.Children[0]); }
public void Import_UseForeshoreButForeshoreProfileWithoutGeometry_LogMessageAndContinueImport() { // Setup string filePath = Path.Combine(importerPath, "validConfigurationCalculationUseForeshoreWithoutGeometry.xml"); var calculationGroup = new CalculationGroup(); var foreshoreProfile = new TestForeshoreProfile("Voorlandprofiel"); var importer = new HeightStructuresCalculationConfigurationImporter( filePath, calculationGroup, Enumerable.Empty <HydraulicBoundaryLocation>(), new[] { foreshoreProfile }, Enumerable.Empty <HeightStructure>()); var successful = false; // Call 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); Assert.IsTrue(successful); CollectionAssert.IsEmpty(calculationGroup.Children); }
public void Import_ValidConfigurationInvalidData_LogMessageAndContinueImport(string file, string expectedErrorMessage) { // Setup string filePath = Path.Combine(importerPath, file); var calculationGroup = new CalculationGroup(); var structure = new TestHeightStructure("kunstwerk1", "kunstwerk1"); var foreshoreProfile = new TestForeshoreProfile("profiel 1"); var importer = new HeightStructuresCalculationConfigurationImporter(filePath, calculationGroup, Enumerable.Empty <HydraulicBoundaryLocation>(), new ForeshoreProfile[] { foreshoreProfile }, new HeightStructure[] { structure }); var successful = false; // Call void Call() => successful = importer.Import(); // Assert string expectedMessage = $"{expectedErrorMessage} Berekening 'Berekening 1' is overgeslagen."; TestHelper.AssertLogMessageWithLevelIsGenerated(Call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 2); Assert.IsTrue(successful); CollectionAssert.IsEmpty(calculationGroup.Children); }
public void Import_StochastWithStandardDeviationOrVariationCoefficientOnly_DataAddedToModel() { // Setup string filePath = Path.Combine(importerPath, "validConfigurationStochastStandardDeviationVariationCoefficientOnly.xml"); var calculationGroup = new CalculationGroup(); var structure = new TestHeightStructure("kunstwerk1", "kunstwerk1"); var importer = new HeightStructuresCalculationConfigurationImporter( filePath, calculationGroup, Enumerable.Empty <HydraulicBoundaryLocation>(), Enumerable.Empty <ForeshoreProfile>(), new[] { structure }); var expectedCalculation = new StructuresCalculationScenario <HeightStructuresInput> { Name = "Berekening 1", InputParameters = { Structure = structure, FlowWidthAtBottomProtection = { StandardDeviation = (RoundedDouble)0.1 }, WidthFlowApertures = { StandardDeviation = (RoundedDouble)0.1 }, StorageStructureArea = { CoefficientOfVariation = (RoundedDouble)0.01 }, AllowedLevelIncreaseStorage = { StandardDeviation = (RoundedDouble)0.01 }, LevelCrestStructure = { StandardDeviation = (RoundedDouble)0.1 }, CriticalOvertoppingDischarge = { CoefficientOfVariation = (RoundedDouble)0.1 } } }; // Call bool successful = importer.Import(); // Assert Assert.IsTrue(successful); Assert.AreEqual(1, calculationGroup.Children.Count); AssertCalculation(expectedCalculation, (StructuresCalculationScenario <HeightStructuresInput>)calculationGroup.Children[0]); }
public void Constructor_ExpectedValues() { // Call var importer = new HeightStructuresCalculationConfigurationImporter("", new CalculationGroup(), Enumerable.Empty <HydraulicBoundaryLocation>(), Enumerable.Empty <ForeshoreProfile>(), Enumerable.Empty <HeightStructure>()); // Assert Assert.IsInstanceOf <CalculationConfigurationImporter <HeightStructuresCalculationConfigurationReader, HeightStructuresCalculationConfiguration> >(importer); }
public void Import_FullCalculationConfiguration_DataAddedToModel() { // Setup string filePath = Path.Combine(importerPath, "validFullConfiguration.xml"); var calculationGroup = new CalculationGroup(); var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("Locatie1"); var foreshoreProfile = new TestForeshoreProfile("profiel1", new List <Point2D> { new Point2D(0, 3) }); var structure = new TestHeightStructure("kunstwerk1"); var importer = new HeightStructuresCalculationConfigurationImporter( filePath, calculationGroup, new[] { hydraulicBoundaryLocation }, new[] { foreshoreProfile }, new[] { structure }); // Call var successful = false; void Call() => successful = importer.Import(); // Assert TestHelper.AssertLogMessageIsGenerated(Call, $"Gegevens zijn geïmporteerd vanuit bestand '{filePath}'.", 1); Assert.IsTrue(successful); var expectedCalculation = new StructuresCalculationScenario <HeightStructuresInput> { Name = "Berekening 1", InputParameters = { HydraulicBoundaryLocation = hydraulicBoundaryLocation, Structure = structure, ForeshoreProfile = foreshoreProfile, StructureNormalOrientation = (RoundedDouble)67.1, FailureProbabilityStructureWithErosion = 1e-6, UseBreakWater = true, UseForeshore = true, ShouldIllustrationPointsBeCalculated = true, BreakWater = { Height = (RoundedDouble)1.23, Type = BreakWaterType.Dam }, StormDuration = { Mean = (RoundedDouble)6.0 }, ModelFactorSuperCriticalFlow = { Mean = (RoundedDouble)1.10 }, FlowWidthAtBottomProtection = { Mean = (RoundedDouble)15.2, StandardDeviation = (RoundedDouble)0.1 }, WidthFlowApertures = { Mean = (RoundedDouble)15.2, StandardDeviation = (RoundedDouble)0.1 }, StorageStructureArea = { Mean = (RoundedDouble)15000, CoefficientOfVariation = (RoundedDouble)0.01 }, AllowedLevelIncreaseStorage = { Mean = (RoundedDouble)0.2, StandardDeviation = (RoundedDouble)0.01 }, LevelCrestStructure = { Mean = (RoundedDouble)4.3, StandardDeviation = (RoundedDouble)0.1 }, CriticalOvertoppingDischarge = { Mean = (RoundedDouble)2, CoefficientOfVariation = (RoundedDouble)0.1 } }, IsRelevant = true, Contribution = (RoundedDouble)0.5432 }; Assert.AreEqual(1, calculationGroup.Children.Count); AssertCalculation(expectedCalculation, (StructuresCalculationScenario <HeightStructuresInput>)calculationGroup.Children[0]); }