Esempio n. 1
0
        public void Import_EmptyConfigurations_DataAddedToModel(string file)
        {
            // Setup
            string filePath = Path.Combine(importerPath, file);

            var calculationGroup = new CalculationGroup();
            var structure        = new TestClosingStructure("kunstwerk1", "kunstwerk1");
            var importer         = new ClosingStructuresCalculationConfigurationImporter(
                filePath,
                calculationGroup,
                Enumerable.Empty <HydraulicBoundaryLocation>(),
                Enumerable.Empty <ForeshoreProfile>(),
                new[]
            {
                structure
            });

            var expectedCalculation = new StructuresCalculationScenario <ClosingStructuresInput>
            {
                Name = "Berekening 1"
            };

            // Call
            bool successful = importer.Import();

            // Assert
            Assert.IsTrue(successful);
            Assert.AreEqual(1, calculationGroup.Children.Count);
            AssertCalculation(expectedCalculation, (StructuresCalculationScenario <ClosingStructuresInput>)calculationGroup.Children[0]);
        }
Esempio n. 2
0
        public void Import_ScenarioWithRelevantSet_DataAddedToModel()
        {
            // Setup
            string filePath = Path.Combine(importerPath, "validConfigurationScenarioRelevantOnly.xml");

            var calculationGroup = new CalculationGroup();

            var importer = new ClosingStructuresCalculationConfigurationImporter(filePath,
                                                                                 calculationGroup,
                                                                                 Enumerable.Empty <HydraulicBoundaryLocation>(),
                                                                                 Enumerable.Empty <ForeshoreProfile>(),
                                                                                 Enumerable.Empty <ClosingStructure>());

            // 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 <ClosingStructuresInput>
            {
                Name       = "Calculation",
                IsRelevant = false
            };

            Assert.AreEqual(1, calculationGroup.Children.Count);
            AssertCalculation(expectedCalculation, (StructuresCalculationScenario <ClosingStructuresInput>)calculationGroup.Children[0]);
        }
Esempio n. 3
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 ClosingStructuresCalculationConfigurationImporter(
                filePath,
                calculationGroup,
                Enumerable.Empty <HydraulicBoundaryLocation>(),
                new[]
            {
                foreshoreProfile
            },
                Enumerable.Empty <ClosingStructure>());

            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);
        }
Esempio n. 4
0
        public void Import_ValidConfigurationInvalidData_LogMessageAndContinueImport(string file, string expectedErrorMessage)
        {
            // Setup
            string filePath = Path.Combine(importerPath, file);

            var calculationGroup = new CalculationGroup();
            var structure        = new TestClosingStructure("kunstwerk1", "kunstwerk1");
            var foreshoreProfile = new TestForeshoreProfile("profiel 1");

            var importer = new ClosingStructuresCalculationConfigurationImporter(filePath,
                                                                                 calculationGroup,
                                                                                 Enumerable.Empty <HydraulicBoundaryLocation>(),
                                                                                 new ForeshoreProfile[]
            {
                foreshoreProfile
            },
                                                                                 new ClosingStructure[]
            {
                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);
        }
Esempio n. 5
0
        public void Constructor_ExpectedValues()
        {
            // Call
            var importer = new ClosingStructuresCalculationConfigurationImporter(
                "", new CalculationGroup(), Enumerable.Empty <HydraulicBoundaryLocation>(),
                Enumerable.Empty <ForeshoreProfile>(), Enumerable.Empty <ClosingStructure>());

            // AssertTC
            Assert.IsInstanceOf <CalculationConfigurationImporter <ClosingStructuresCalculationConfigurationReader, ClosingStructuresCalculationConfiguration> >(importer);
        }
Esempio n. 6
0
        public void Import_StochastWithStandardDeviationOrVariationCoefficientOnly_DataAddedToModel()
        {
            // Setup
            string filePath = Path.Combine(importerPath, "validConfigurationStochastStandardDeviationVariationCoefficientOnly.xml");

            var calculationGroup = new CalculationGroup();
            var structure        = new TestClosingStructure("kunstwerk1", "kunstwerk1");
            var importer         = new ClosingStructuresCalculationConfigurationImporter(
                filePath,
                calculationGroup,
                Enumerable.Empty <HydraulicBoundaryLocation>(),
                Enumerable.Empty <ForeshoreProfile>(),
                new[]
            {
                structure
            });

            var expectedCalculation = new StructuresCalculationScenario <ClosingStructuresInput>
            {
                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
                    },
                    CriticalOvertoppingDischarge  =
                    {
                        CoefficientOfVariation    = (RoundedDouble)0.1
                    },
                    LevelCrestStructureNotClosing =
                    {
                        StandardDeviation         = (RoundedDouble)0.2
                    },
                    AreaFlowApertures             =
                    {
                        StandardDeviation         = (RoundedDouble)1
                    },
                    DrainCoefficient              =
                    {
                        StandardDeviation         = (RoundedDouble)0.1
                    },
                    InsideWaterLevel              =
                    {
                        StandardDeviation         = (RoundedDouble)0.1
                    },
                    ThresholdHeightOpenWeir       =
                    {
                        StandardDeviation         = (RoundedDouble)0.1
                    }
                }
            };

            // Call
            bool successful = importer.Import();

            // Assert
            Assert.IsTrue(successful);
            Assert.AreEqual(1, calculationGroup.Children.Count);
            AssertCalculation(expectedCalculation, (StructuresCalculationScenario <ClosingStructuresInput>)calculationGroup.Children[0]);
        }
Esempio n. 7
0
        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 TestClosingStructure("kunstwerk1", "kunstwerk1");
            var importer  = new ClosingStructuresCalculationConfigurationImporter(
                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 <ClosingStructuresInput>
            {
                Name            = "Berekening 1",
                InputParameters =
                {
                    HydraulicBoundaryLocation              = hydraulicBoundaryLocation,
                    Structure                              = structure,
                    ForeshoreProfile                       = foreshoreProfile,
                    StructureNormalOrientation             = (RoundedDouble)67.1,
                    IdenticalApertures                     =                                            4,
                    InflowModelType                        = ClosingStructureInflowModelType.VerticalWall,
                    FailureProbabilityStructureWithErosion =                                        0.001,
                    FactorStormDurationOpenStructure       = (RoundedDouble)0.002,
                    ProbabilityOpenStructureBeforeFlooding =                                         0.03,
                    FailureProbabilityOpenStructure        =                                         0.22,
                    FailureProbabilityReparation           =                                       0.0006,
                    ShouldIllustrationPointsBeCalculated   = true,
                    UseBreakWater                          = true,
                    UseForeshore                           = 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
                    },
                    CriticalOvertoppingDischarge           =
                    {
                        Mean                               = (RoundedDouble)2,
                        CoefficientOfVariation             = (RoundedDouble)0.1
                    },
                    LevelCrestStructureNotClosing          =
                    {
                        Mean                               = (RoundedDouble)4.3,
                        StandardDeviation                  = (RoundedDouble)0.2
                    },
                    AreaFlowApertures                      =
                    {
                        Mean                               = (RoundedDouble)80.5,
                        StandardDeviation                  = (RoundedDouble)1
                    },
                    DrainCoefficient                       =
                    {
                        Mean                               = (RoundedDouble)1.1,
                        StandardDeviation                  = (RoundedDouble)0.1
                    },
                    InsideWaterLevel                       =
                    {
                        Mean                               = (RoundedDouble)0.5,
                        StandardDeviation                  = (RoundedDouble)0.1
                    },
                    ThresholdHeightOpenWeir                =
                    {
                        Mean                               = (RoundedDouble)1.2,
                        StandardDeviation                  = (RoundedDouble)0.1
                    }
                },
                IsRelevant   = true,
                Contribution = (RoundedDouble)0.5432
            };

            Assert.AreEqual(1, calculationGroup.Children.Count);
            AssertCalculation(expectedCalculation, (StructuresCalculationScenario <ClosingStructuresInput>)calculationGroup.Children[0]);
        }