public void Import_StochastsWithNoParametersSet_DataAddedToModel()
            {
                // Setup
                string filePath = TestHelper.GetScratchPadPath(nameof(Import_StochastsWithNoParametersSet_DataAddedToModel));

                SetCalculationType(Path.Combine(importerPath, "validConfigurationStochastsNoParameters.xml"), filePath);

                var calculationGroup = new CalculationGroup();

                var pipingFailureMechanism = new PipingFailureMechanism();

                var importer = new PipingCalculationConfigurationImporter(
                    filePath, calculationGroup, Enumerable.Empty <HydraulicBoundaryLocation>(), pipingFailureMechanism);

                try
                {
                    // Call
                    var successful            = false;
                    void Call() => successful = importer.Import();

                    // Assert
                    TestHelper.AssertLogMessageIsGenerated(Call, $"Gegevens zijn geïmporteerd vanuit bestand '{filePath}'.", 1);
                    Assert.IsTrue(successful);

                    TCalculationScenario expectedCalculation = CreateCalculationScenario();
                    expectedCalculation.Name = "Calculation";

                    Assert.AreEqual(1, calculationGroup.Children.Count);
                    AssertPipingCalculationScenario(expectedCalculation, (TCalculationScenario)calculationGroup.Children[0]);
                }
                finally
                {
                    File.Delete(filePath);
                }
            }
            public void Import_EntryAndOrExitPointDefinedWithoutSurfaceLine_LogMessageAndContinueImport(string file)
            {
                // Setup
                string filePath = TestHelper.GetScratchPadPath(nameof(Import_EntryAndOrExitPointDefinedWithoutSurfaceLine_LogMessageAndContinueImport));

                SetCalculationType(Path.Combine(importerPath, file), filePath);

                var calculationGroup       = new CalculationGroup();
                var pipingFailureMechanism = new PipingFailureMechanism();
                var importer = new PipingCalculationConfigurationImporter(
                    filePath, calculationGroup, new HydraulicBoundaryLocation[0], pipingFailureMechanism);

                try
                {
                    // Call
                    var successful            = false;
                    void Call() => successful = importer.Import();

                    // Assert
                    const string expectedMessage = "Er is geen profielschematisatie, maar wel een intrede- of uittredepunt opgegeven. " +
                                                   "Berekening 'Calculation' is overgeslagen.";
                    TestHelper.AssertLogMessageIsGenerated(Call, expectedMessage, 2);
                    Assert.IsTrue(successful);
                    CollectionAssert.IsEmpty(calculationGroup.Children);
                }
                finally
                {
                    File.Delete(filePath);
                }
            }
            public void Import_StochasticSoilProfileSpecifiedWithoutSoilModel_LogMessageAndContinueImport()
            {
                // Setup
                string filePath = TestHelper.GetScratchPadPath(nameof(Import_StochasticSoilProfileSpecifiedWithoutSoilModel_LogMessageAndContinueImport));

                SetCalculationType(Path.Combine(importerPath, "validConfigurationCalculationContainingSoilProfileWithoutSoilModel.xml"), filePath);

                var calculationGroup       = new CalculationGroup();
                var pipingFailureMechanism = new PipingFailureMechanism();

                var importer = new PipingCalculationConfigurationImporter(
                    filePath, calculationGroup, new HydraulicBoundaryLocation[0], pipingFailureMechanism);

                try
                {
                    // Call
                    var successful            = false;
                    void Call() => successful = importer.Import();

                    // Assert
                    const string expectedMessage = "Er is geen stochastisch ondergrondmodel opgegeven bij ondergrondschematisatie 'Ondergrondschematisatie'. " +
                                                   "Berekening 'Calculation' is overgeslagen.";
                    TestHelper.AssertLogMessageIsGenerated(Call, expectedMessage, 2);
                    Assert.IsTrue(successful);
                    CollectionAssert.IsEmpty(calculationGroup.Children);
                }
                finally
                {
                    File.Delete(filePath);
                }
            }
            public void Import_SurfaceLineUnknown_LogMessageAndContinueImport()
            {
                // Setup
                string filePath = TestHelper.GetScratchPadPath(nameof(Import_SurfaceLineUnknown_LogMessageAndContinueImport));

                SetCalculationType(Path.Combine(importerPath, "validConfigurationCalculationContainingUnknownSurfaceLine.xml"), filePath);

                var calculationGroup = new CalculationGroup();

                var importer = new PipingCalculationConfigurationImporter(
                    filePath, calculationGroup, new HydraulicBoundaryLocation[0], new PipingFailureMechanism());

                try
                {
                    // Call
                    var successful            = false;
                    void Call() => successful = importer.Import();

                    // Assert
                    const string expectedMessage = "De profielschematisatie 'Profielschematisatie' bestaat niet. Berekening 'Calculation' is overgeslagen.";
                    TestHelper.AssertLogMessageIsGenerated(Call, expectedMessage, 2);
                    Assert.IsTrue(successful);
                    CollectionAssert.IsEmpty(calculationGroup.Children);
                }
                finally
                {
                    File.Delete(filePath);
                }
            }
        public void Constructor_ExpectedValues()
        {
            // Call
            var importer = new PipingCalculationConfigurationImporter(
                "", new CalculationGroup(), Enumerable.Empty <HydraulicBoundaryLocation>(), new PipingFailureMechanism());

            // Assert
            Assert.IsInstanceOf <CalculationConfigurationImporter <PipingCalculationConfigurationReader, PipingCalculationConfiguration> >(importer);
        }
            public void Import_StochasticSoilProfileUnknown_LogMessageAndContinueImport()
            {
                // Setup
                string filePath = TestHelper.GetScratchPadPath(nameof(Import_StochasticSoilProfileUnknown_LogMessageAndContinueImport));

                SetCalculationType(Path.Combine(importerPath, "validConfigurationCalculationContainingUnknownSoilProfile.xml"), filePath);

                var calculationGroup = new CalculationGroup();
                var surfaceLine      = new PipingSurfaceLine("Profielschematisatie");

                surfaceLine.SetGeometry(new[]
                {
                    new Point3D(3.0, 5.0, 0.0),
                    new Point3D(3.0, 0.0, 1.0),
                    new Point3D(3.0, -5.0, 0.0)
                });
                PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(
                    "Ondergrondmodel",
                    new[]
                {
                    new Point2D(1.0, 0.0),
                    new Point2D(5.0, 0.0)
                });

                var pipingFailureMechanism = new PipingFailureMechanism();

                pipingFailureMechanism.SurfaceLines.AddRange(new[]
                {
                    surfaceLine
                }, "readerPath");
                pipingFailureMechanism.StochasticSoilModels.AddRange(new[]
                {
                    stochasticSoilModel
                }, "readerPath");

                var importer = new PipingCalculationConfigurationImporter(
                    filePath, calculationGroup, new HydraulicBoundaryLocation[0], pipingFailureMechanism);

                try
                {
                    // Call
                    var successful            = false;
                    void Call() => successful = importer.Import();

                    // Assert
                    const string expectedMessage = "De ondergrondschematisatie 'Ondergrondschematisatie' bestaat niet binnen het stochastische ondergrondmodel 'Ondergrondmodel'. " +
                                                   "Berekening 'Calculation' is overgeslagen.";
                    TestHelper.AssertLogMessageIsGenerated(Call, expectedMessage, 2);
                    Assert.IsTrue(successful);
                    CollectionAssert.IsEmpty(calculationGroup.Children);
                }
                finally
                {
                    File.Delete(filePath);
                }
            }
            public void Import_ValidConfigurationInvalidData_LogMessageAndContinueImport(string file, string expectedErrorMessage)
            {
                // Setup
                string filePath = TestHelper.GetScratchPadPath(nameof(Import_ValidConfigurationInvalidData_LogMessageAndContinueImport));

                SetCalculationType(Path.Combine(importerPath, file), filePath);

                var calculationGroup = new CalculationGroup();
                var surfaceLine      = new PipingSurfaceLine("Profielschematisatie");

                surfaceLine.SetGeometry(new[]
                {
                    new Point3D(3.0, 5.0, 0.0),
                    new Point3D(3.0, 0.0, 1.0),
                    new Point3D(3.0, -5.0, 0.0)
                });

                var pipingFailureMechanism = new PipingFailureMechanism();

                pipingFailureMechanism.SurfaceLines.AddRange(new[]
                {
                    surfaceLine
                }, "readerPath");

                var importer = new PipingCalculationConfigurationImporter(
                    filePath, calculationGroup, new HydraulicBoundaryLocation[0], pipingFailureMechanism);

                var successful = false;

                try
                {
                    // Call
                    void Call() => successful = importer.Import();

                    // Assert
                    var expectedMessage = $"{expectedErrorMessage} Berekening 'Calculation' is overgeslagen.";
                    TestHelper.AssertLogMessageIsGenerated(Call, expectedMessage, 2);
                    Assert.IsTrue(successful);
                    CollectionAssert.IsEmpty(calculationGroup.Children);
                }
                finally
                {
                    File.Delete(filePath);
                }
            }
            public void Import_ValidConfigurationFullProbabilisticCalculationWithValidHydraulicBoundaryData_DataAddedToModel()
            {
                // Setup
                string filePath = Path.Combine(importerPath, "validConfigurationFullProbabilisticCalculation.xml");

                var calculationGroup = new CalculationGroup();
                var surfaceLine      = new PipingSurfaceLine("Profielschematisatie");

                surfaceLine.SetGeometry(new[]
                {
                    new Point3D(3.0, 5.0, 0.0),
                    new Point3D(3.0, 0.0, 1.0),
                    new Point3D(3.0, -5.0, 0.0)
                });
                var stochasticSoilProfile = new PipingStochasticSoilProfile(0, new PipingSoilProfile("Ondergrondschematisatie", 0, new[]
                {
                    new PipingSoilLayer(0)
                }, SoilProfileType.SoilProfile1D));

                var stochasticSoilModel = new PipingStochasticSoilModel("Ondergrondmodel", new[]
                {
                    new Point2D(1.0, 0.0),
                    new Point2D(5.0, 0.0)
                }, new[]
                {
                    stochasticSoilProfile
                });

                var pipingFailureMechanism = new PipingFailureMechanism();

                pipingFailureMechanism.SurfaceLines.AddRange(new[]
                {
                    surfaceLine
                }, "readerPath");
                pipingFailureMechanism.StochasticSoilModels.AddRange(new[]
                {
                    stochasticSoilModel
                }, "readerPath");

                var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "Locatie", 10, 20);
                var importer = new PipingCalculationConfigurationImporter(filePath,
                                                                          calculationGroup,
                                                                          new[]
                {
                    hydraulicBoundaryLocation
                },
                                                                          pipingFailureMechanism);

                // 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 ProbabilisticPipingCalculationScenario
                {
                    Name            = "Calculation",
                    InputParameters =
                    {
                        HydraulicBoundaryLocation                           = hydraulicBoundaryLocation,
                        SurfaceLine           = surfaceLine,
                        EntryPointL           = (RoundedDouble)2.2,
                        ExitPointL            = (RoundedDouble)3.3,
                        StochasticSoilModel   = stochasticSoilModel,
                        StochasticSoilProfile = stochasticSoilProfile,
                        PhreaticLevelExit     =
                        {
                            Mean                                            = (RoundedDouble)4.4,
                            StandardDeviation                               = (RoundedDouble)5.5
                        },
                        DampingFactorExit                                   =
                        {
                            Mean                                            = (RoundedDouble)6.6,
                            StandardDeviation                               = (RoundedDouble)7.7
                        },
                        ShouldProfileSpecificIllustrationPointsBeCalculated = true,
                        ShouldSectionSpecificIllustrationPointsBeCalculated = true
                    },
                    Contribution = (RoundedDouble)0.088,
                    IsRelevant   = false
                };

                Assert.AreEqual(1, calculationGroup.Children.Count);
                AssertPipingCalculationScenario(expectedCalculation, (ProbabilisticPipingCalculationScenario)calculationGroup.Children[0]);
            }