public void ReadWaveReduction_WithConfigurationWithMissingParameter_MissingParameterUnchanged( [Values(0, 1, 2, 3)] int parameterNotSet) { // Setup const bool useForeshoreProfile = false; const bool useBreakWater = false; const double height = 2.55; const BreakWaterType breakWaterType = BreakWaterType.Dam; const bool newUseForeshoreProfile = true; const bool newUseBreakWater = true; const double newHeight = 11.1; const ConfigurationBreakWaterType newBreakWaterType = ConfigurationBreakWaterType.Wall; const BreakWaterType expectedNewBreakWaterType = BreakWaterType.Wall; var testInput = new TestInputWithForeshoreProfileAndBreakWater(new BreakWater(breakWaterType, height)) { UseBreakWater = useBreakWater, UseForeshore = useForeshoreProfile }; var waveReductionConfiguration = new WaveReductionConfiguration(); if (parameterNotSet != 0) { waveReductionConfiguration.UseForeshoreProfile = newUseForeshoreProfile; } if (parameterNotSet != 1) { waveReductionConfiguration.UseBreakWater = newUseBreakWater; } if (parameterNotSet != 2) { waveReductionConfiguration.BreakWaterHeight = newHeight; } if (parameterNotSet != 3) { waveReductionConfiguration.BreakWaterType = newBreakWaterType; } string filePath = Path.Combine(readerPath, "validConfiguration.xml"); var calculationGroup = new CalculationGroup(); var importer = new CalculationConfigurationImporter(filePath, calculationGroup); // Call importer.PublicReadWaveReductionParameters(waveReductionConfiguration, testInput); // Assert Assert.AreEqual(testInput.UseForeshore, parameterNotSet == 0 ? useForeshoreProfile : newUseForeshoreProfile); Assert.AreEqual(testInput.UseBreakWater, parameterNotSet == 1 ? useBreakWater : newUseBreakWater); Assert.AreEqual(testInput.BreakWater.Height, parameterNotSet == 2 ? height : newHeight, testInput.BreakWater.Height.GetAccuracy()); Assert.AreEqual(testInput.BreakWater.Type, parameterNotSet == 3 ? breakWaterType : expectedNewBreakWaterType); }
public void SimpleProperties_SetNewValues_NewValuesSet() { // Setup const string calculationName = "Name of the calculation"; const string hydraulicBoundaryLocation = "Name of the hydraulic boundary location"; const double targetProbability = 1.1; const double upperBoundaryRevetment = 2.2; const double lowerBoundaryRevetment = 3.3; const double upperBoundaryWaterLevels = 4.4; const double lowerBoundaryWaterLevels = 5.5; const ConfigurationWaveConditionsInputStepSize stepSize = ConfigurationWaveConditionsInputStepSize.Half; const string foreshoreProfileName = "Name of the foreshore profile"; const double orientation = 6.6; const bool useBreakWater = true; const ConfigurationBreakWaterType breakWaterType = ConfigurationBreakWaterType.Caisson; const double breakWaterHeight = 7.7; const bool useForeshore = false; // Call var readWaveConditionsCalculation = new WaveConditionsCalculationConfiguration(calculationName) { HydraulicBoundaryLocationName = hydraulicBoundaryLocation, TargetProbability = targetProbability, UpperBoundaryRevetment = upperBoundaryRevetment, LowerBoundaryRevetment = lowerBoundaryRevetment, UpperBoundaryWaterLevels = upperBoundaryWaterLevels, LowerBoundaryWaterLevels = lowerBoundaryWaterLevels, StepSize = stepSize, ForeshoreProfileId = foreshoreProfileName, Orientation = orientation, WaveReduction = new WaveReductionConfiguration { UseBreakWater = useBreakWater, BreakWaterType = breakWaterType, BreakWaterHeight = breakWaterHeight, UseForeshoreProfile = useForeshore } }; // Assert Assert.AreEqual(calculationName, readWaveConditionsCalculation.Name); Assert.AreEqual(hydraulicBoundaryLocation, readWaveConditionsCalculation.HydraulicBoundaryLocationName); Assert.AreEqual(targetProbability, readWaveConditionsCalculation.TargetProbability); Assert.AreEqual(upperBoundaryRevetment, readWaveConditionsCalculation.UpperBoundaryRevetment); Assert.AreEqual(lowerBoundaryRevetment, readWaveConditionsCalculation.LowerBoundaryRevetment); Assert.AreEqual(upperBoundaryWaterLevels, readWaveConditionsCalculation.UpperBoundaryWaterLevels); Assert.AreEqual(lowerBoundaryWaterLevels, readWaveConditionsCalculation.LowerBoundaryWaterLevels); Assert.AreEqual(stepSize, readWaveConditionsCalculation.StepSize); Assert.AreEqual(foreshoreProfileName, readWaveConditionsCalculation.ForeshoreProfileId); Assert.AreEqual(orientation, readWaveConditionsCalculation.Orientation); Assert.AreEqual(useBreakWater, readWaveConditionsCalculation.WaveReduction.UseBreakWater); Assert.AreEqual(breakWaterType, readWaveConditionsCalculation.WaveReduction.BreakWaterType); Assert.AreEqual(breakWaterHeight, readWaveConditionsCalculation.WaveReduction.BreakWaterHeight); Assert.AreEqual(useForeshore, readWaveConditionsCalculation.WaveReduction.UseForeshoreProfile); }
public void ConvertTo_VariousCases_ReturnExpectedText(ConfigurationBreakWaterType value, string expectedResult) { // Setup var converter = new ConfigurationBreakWaterTypeConverter(); // Call object result = converter.ConvertTo(value, typeof(string)); // Assert Assert.AreEqual(expectedResult, result); }
public void ConvertFrom_BreakWaterType_ReturnExpectedBreakWaterType(BreakWaterType value, ConfigurationBreakWaterType expectedResult) { // Setup var converter = new ConfigurationBreakWaterTypeConverter(); // Call object result = converter.ConvertFrom(value); // Assert Assert.AreEqual(expectedResult, result); }
public void ConvertTo_InvalidBreakWaterType_ThrowInvalidEnumArgumentException(Type destinationType) { // Setup var converter = new ConfigurationBreakWaterTypeConverter(); const ConfigurationBreakWaterType invalidValue = (ConfigurationBreakWaterType)99999999; // Call TestDelegate call = () => converter.ConvertTo(invalidValue, destinationType); // Assert string expectedMessage = $"The value of argument 'value' ({invalidValue}) is invalid for Enum type '{nameof(ConfigurationBreakWaterType)}'."; string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(call, expectedMessage).ParamName; Assert.AreEqual("value", parameterName); }
public void ReadWaveReduction_DifferentScenarios_CorrectParametersSet(bool useForeshoreProfile, bool useBreakWater, double height, ConfigurationBreakWaterType type, BreakWaterType expectedType) { // Setup var testInput = new TestInputWithForeshoreProfileAndBreakWater(new BreakWater(BreakWaterType.Caisson, 0.0)); string filePath = Path.Combine(readerPath, "validConfiguration.xml"); var calculationGroup = new CalculationGroup(); var importer = new CalculationConfigurationImporter(filePath, calculationGroup); var waveReductionConfiguration = new WaveReductionConfiguration { UseForeshoreProfile = useForeshoreProfile, UseBreakWater = useBreakWater, BreakWaterHeight = height, BreakWaterType = type }; // Call importer.PublicReadWaveReductionParameters(waveReductionConfiguration, testInput); // Assert Assert.AreEqual(testInput.UseForeshore, useForeshoreProfile); Assert.AreEqual(testInput.UseBreakWater, useBreakWater); Assert.AreEqual(testInput.BreakWater.Height, height, testInput.BreakWater.Height.GetAccuracy()); Assert.AreEqual(testInput.BreakWater.Type, expectedType); }