Exemple #1
0
        public void Write_SparseCalculation_WritesSparseConfigurationToFile()
        {
            // Setup
            string filePath = TestHelper.GetScratchPadPath(
                $"{nameof(Write_SparseCalculation_WritesSparseConfigurationToFile)}.xml");

            string expectedXmlFilePath = TestHelper.GetTestDataPath(
                TestDataPath.Riskeer.Revetment.IO,
                Path.Combine(nameof(WaveConditionsCalculationConfigurationWriter <WaveConditionsCalculationConfiguration>), "sparseConfiguration.xml"));

            var calculation = new WaveConditionsCalculationConfiguration("Berekening 1");

            try
            {
                var writer = new TestWaveConditionsCalculationConfigurationWriter(filePath);

                // Call
                writer.Write(new[]
                {
                    calculation
                });

                // Assert
                string actualXml   = File.ReadAllText(filePath);
                string expectedXml = File.ReadAllText(expectedXmlFilePath);

                Assert.AreEqual(expectedXml, actualXml);
            }
            finally
            {
                File.Delete(filePath);
            }
        }
Exemple #2
0
        public void Write_CompleteCalculation_WritesCompleteConfigurationToFile()
        {
            // Setup
            string filePath = TestHelper.GetScratchPadPath(
                $"{nameof(Write_CompleteCalculation_WritesCompleteConfigurationToFile)}.xml");

            string expectedXmlFilePath = TestHelper.GetTestDataPath(
                TestDataPath.Riskeer.Revetment.IO,
                Path.Combine(nameof(WaveConditionsCalculationConfigurationWriter <WaveConditionsCalculationConfiguration>), "completeConfiguration.xml"));

            var calculation = new WaveConditionsCalculationConfiguration("Berekening 1")
            {
                HydraulicBoundaryLocationName = "Locatie1",
                TargetProbability             = 0.01,
                UpperBoundaryRevetment        = (RoundedDouble)1.5,
                LowerBoundaryRevetment        = (RoundedDouble)0.5,
                UpperBoundaryWaterLevels      = (RoundedDouble)1.4,
                LowerBoundaryWaterLevels      = (RoundedDouble)0.6,
                StepSize           = ConfigurationWaveConditionsInputStepSize.One,
                ForeshoreProfileId = "profiel1",
                Orientation        = (RoundedDouble)67.1,
                WaveReduction      = new WaveReductionConfiguration
                {
                    UseForeshoreProfile = true,
                    UseBreakWater       = true,
                    BreakWaterHeight    = (RoundedDouble)1.23,
                    BreakWaterType      = ConfigurationBreakWaterType.Dam
                }
            };

            try
            {
                var writer = new TestWaveConditionsCalculationConfigurationWriter(filePath);

                // Call
                writer.Write(new[]
                {
                    calculation
                });

                // Assert
                string actualXml   = File.ReadAllText(filePath);
                string expectedXml = File.ReadAllText(expectedXmlFilePath);

                Assert.AreEqual(expectedXml, actualXml);
            }
            finally
            {
                File.Delete(filePath);
            }
        }
Exemple #3
0
        public void Write_InvalidStepSize_ThrowsCriticalFileWriteException()
        {
            // Setup
            var configuration = new WaveConditionsCalculationConfiguration("fail")
            {
                StepSize = (ConfigurationWaveConditionsInputStepSize?)9000
            };

            var writer = new TestWaveConditionsCalculationConfigurationWriter("valid");

            // Call
            TestDelegate call = () => writer.Write(new[]
            {
                configuration
            });

            // Assert
            var exception = Assert.Throws <CriticalFileWriteException>(call);

            Assert.IsInstanceOf <InvalidEnumArgumentException>(exception.InnerException);
        }