public void Import_UseForeshoreTrueButProfileWithoutForeshoreGeometry_LogMessageAndContinueImport() { // Setup string filePath = Path.Combine(path, "validConfigurationCalculationUseForeshoreTrueForeshoreProfileWithoutGeometry.xml"); var calculationGroup = new CalculationGroup(); var foreshoreProfile = new TestForeshoreProfile("Voorlandprofiel"); var importer = new TestWaveConditionsCalculationConfigurationImporter( filePath, calculationGroup, Enumerable.Empty <HydraulicBoundaryLocation>(), new[] { foreshoreProfile }, new FailureMechanismContribution(0.1, 0.1), Enumerable.Empty <HydraulicBoundaryLocationCalculationsForTargetProbability>()); // Call var successful = false; Action 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_WaveReductionWithoutForeshoreProfile_LogMessageAndContinueImport() { // Setup string filePath = Path.Combine(path, "validConfigurationCalculationContainingWaveReductionWithoutForeshoreProfile.xml"); var calculationGroup = new CalculationGroup(); var importer = new TestWaveConditionsCalculationConfigurationImporter( filePath, calculationGroup, Enumerable.Empty <HydraulicBoundaryLocation>(), Enumerable.Empty <ForeshoreProfile>(), new FailureMechanismContribution(0.1, 0.1), Enumerable.Empty <HydraulicBoundaryLocationCalculationsForTargetProbability>()); // Call var successful = false; Action call = () => successful = importer.Import(); // Assert const string expectedMessage = "Er is geen voorlandprofiel opgegeven om golfreductie parameters aan toe te voegen. Berekening 'Berekening 1' is overgeslagen."; TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 2); Assert.IsTrue(successful); CollectionAssert.IsEmpty(calculationGroup.Children); }
public void Import_HydraulicBoundaryLocationUnknown_LogMessageAndContinueImport() { // Setup string filePath = Path.Combine(path, "validConfigurationCalculationContainingUnknownHydraulicBoundaryLocation.xml"); var calculationGroup = new CalculationGroup(); var importer = new TestWaveConditionsCalculationConfigurationImporter( filePath, calculationGroup, Enumerable.Empty <HydraulicBoundaryLocation>(), Enumerable.Empty <ForeshoreProfile>(), new FailureMechanismContribution(0.1, 0.1), Enumerable.Empty <HydraulicBoundaryLocationCalculationsForTargetProbability>()); // Call var successful = false; Action call = () => successful = importer.Import(); // Assert const string expectedMessage = "De hydraulische belastingenlocatie 'Locatie' bestaat niet. Berekening 'Berekening 1' is overgeslagen."; TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 2); Assert.IsTrue(successful); CollectionAssert.IsEmpty(calculationGroup.Children); }
public void Constructor_ExpectedValues() { // Call var importer = new TestWaveConditionsCalculationConfigurationImporter( "", new CalculationGroup(), Enumerable.Empty <HydraulicBoundaryLocation>(), Enumerable.Empty <ForeshoreProfile>(), new FailureMechanismContribution(0.1, 0.1), Enumerable.Empty <HydraulicBoundaryLocationCalculationsForTargetProbability>()); // Assert Assert.IsInstanceOf <CalculationConfigurationImporter <TestWaveConditionsCalculationConfigurationReader, WaveConditionsCalculationConfiguration> >(importer); }
public void GivenDataModelWithUnmatchableTargetProbabilities_WhenImporting_ThenLogMessageAndContinueImport( FailureMechanismContribution failureMechanismContribution, IEnumerable <HydraulicBoundaryLocationCalculationsForTargetProbability> calculationsForTargetProbabilities) { // Setup string filePath = Path.Combine(path, "validConfigurationFullCalculation.xml"); var calculationGroup = new CalculationGroup(); var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "Locatie", 10, 20); var foreshoreProfile = new ForeshoreProfile(new Point2D(0, 0), new[] { new Point2D(0, 0), new Point2D(1, 1), new Point2D(2, 2) }, new BreakWater(BreakWaterType.Caisson, 0), new ForeshoreProfile.ConstructionProperties { Id = "Voorlandprofiel", Name = "VoorlandProfielName" }); var importer = new TestWaveConditionsCalculationConfigurationImporter( filePath, calculationGroup, new[] { hydraulicBoundaryLocation }, new[] { foreshoreProfile }, failureMechanismContribution, calculationsForTargetProbabilities); // Call var successful = false; Action call = () => successful = importer.Import(); // Assert const string expectedMessage = "De doelkans '0.01' kan niet worden gevonden 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_UseForeshoreFalseButProfileWithoutForeshoreGeometry_DataAddedToModel() { // Setup string filePath = Path.Combine(path, "validConfigurationCalculationUseForeshoreFalseForeshoreProfileWithoutGeometry.xml"); var calculationGroup = new CalculationGroup(); var foreshoreProfile = new TestForeshoreProfile("Voorlandprofiel"); var importer = new TestWaveConditionsCalculationConfigurationImporter( filePath, calculationGroup, Enumerable.Empty <HydraulicBoundaryLocation>(), new[] { foreshoreProfile }, new FailureMechanismContribution(0.1, 0.1), Enumerable.Empty <HydraulicBoundaryLocationCalculationsForTargetProbability>()); // Call bool successful = importer.Import(); // Assert Assert.IsTrue(successful); var expectedCalculation = new TestTargetTestWaveConditionsCalculation { Name = "Berekening 1", InputParameters = { UseForeshore = false, Orientation = (RoundedDouble)0, ForeshoreProfile = foreshoreProfile, WaterLevelType = WaveConditionsInputWaterLevelType.MaximumAllowableFloodingProbability } }; Assert.AreEqual(1, calculationGroup.Children.Count); AssertWaveConditionsCalculation(expectedCalculation, (ICalculation <WaveConditionsInput>)calculationGroup.Children[0]); }
public void Import_ValidConfigurationWithValidData_DataAddedToModel(FailureMechanismContribution failureMechanismContribution, HydraulicBoundaryLocationCalculationsForTargetProbability calculationsForTargetProbability, WaveConditionsInputWaterLevelType expectedWaterLevelType) { // Setup string filePath = Path.Combine(path, "validConfigurationFullCalculation.xml"); var calculationGroup = new CalculationGroup(); var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "Locatie", 10, 20); var foreshoreProfile = new ForeshoreProfile(new Point2D(0, 0), new[] { new Point2D(0, 0), new Point2D(1, 1), new Point2D(2, 2) }, new BreakWater(BreakWaterType.Caisson, 0), new ForeshoreProfile.ConstructionProperties { Id = "Voorlandprofiel", Name = "VoorlandProfielName" }); var importer = new TestWaveConditionsCalculationConfigurationImporter( filePath, calculationGroup, new[] { hydraulicBoundaryLocation }, new[] { foreshoreProfile }, failureMechanismContribution, new[] { calculationsForTargetProbability }); // 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 TestTargetTestWaveConditionsCalculation { Name = "Berekening 1", InputParameters = { HydraulicBoundaryLocation = hydraulicBoundaryLocation, CalculationsTargetProbability = expectedWaterLevelType == WaveConditionsInputWaterLevelType.UserDefinedTargetProbability ? calculationsForTargetProbability : null, WaterLevelType = expectedWaterLevelType, UpperBoundaryRevetment = (RoundedDouble)10, LowerBoundaryRevetment = (RoundedDouble)2, UpperBoundaryWaterLevels = (RoundedDouble)9, LowerBoundaryWaterLevels = (RoundedDouble)4, StepSize = WaveConditionsInputStepSize.Half, ForeshoreProfile = foreshoreProfile, Orientation = (RoundedDouble)5.5, UseForeshore = false, UseBreakWater = true, BreakWater = { Height = (RoundedDouble)6.6, Type = BreakWaterType.Caisson } } }; Assert.AreEqual(1, calculationGroup.Children.Count); AssertWaveConditionsCalculation(expectedCalculation, (ICalculation <WaveConditionsInput>)calculationGroup.Children[0]); }