public void ReadWaveReduction_WithoutConfiguration_ParametersUnchanged() { // Setup var random = new Random(21); bool useForeshoreProfile = random.NextBoolean(); bool useBreakWater = random.NextBoolean(); double height = random.NextDouble(); var breakWaterType = random.NextEnumValue<BreakWaterType>(); var testInput = new TestInputWithForeshoreProfileAndBreakWater(new BreakWater(breakWaterType, height)) { UseBreakWater = useBreakWater, UseForeshore = useForeshoreProfile }; string filePath = Path.Combine(readerPath, "validConfiguration.xml"); var calculationGroup = new CalculationGroup(); var importer = new CalculationConfigurationImporter(filePath, calculationGroup); // Call importer.PublicReadWaveReductionParameters(null, 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, breakWaterType); }
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); }
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); }