Пример #1
0
        public void AssembleSectionAdoptableSectionWithoutProfileProbability_WithInput_ReturnsExpectedOutput(
            AdoptableInitialFailureMechanismResultType initialFailureMechanismResultType, bool expectedHasProbabilitySpecified)
        {
            // Setup
            var    random     = new Random(21);
            bool   isRelevant = random.NextBoolean();
            double manualSectionProbability     = random.NextDouble();
            double calculatedSectionProbability = random.NextDouble();
            var    furtherAnalysisType          = random.NextEnumValue <FailureMechanismSectionResultFurtherAnalysisType>();
            double refinedSectionProbability    = random.NextDouble();

            var assessmentSection = new AssessmentSectionStub();

            var sectionResult = new AdoptableFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
            {
                IsRelevant = isRelevant,
                InitialFailureMechanismResultType = initialFailureMechanismResultType,
                ManualInitialFailureMechanismResultSectionProbability = manualSectionProbability,
                FurtherAnalysisType       = furtherAnalysisType,
                RefinedSectionProbability = refinedSectionProbability
            };

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;

                // Call
                FailureMechanismSectionAssemblyResultFactory.AssembleSection(sectionResult, assessmentSection, () => calculatedSectionProbability);

                // Assert
                FailureMechanismSectionAssemblyInput calculatorInput = calculator.FailureMechanismSectionAssemblyInput;
                FailureMechanismContribution         failureMechanismContribution = assessmentSection.FailureMechanismContribution;
                Assert.AreEqual(failureMechanismContribution.SignalFloodingProbability, calculatorInput.SignalFloodingProbability);
                Assert.AreEqual(failureMechanismContribution.MaximumAllowableFloodingProbability, calculatorInput.MaximumAllowableFloodingProbability);

                Assert.AreEqual(isRelevant, calculatorInput.IsRelevant);
                Assert.AreEqual(expectedHasProbabilitySpecified, calculatorInput.HasProbabilitySpecified);

                double expectedInitialSectionProbability = IsInitialFailureMechanismResultTypeAdopt(initialFailureMechanismResultType)
                                                               ? calculatedSectionProbability
                                                               : manualSectionProbability;
                Assert.AreEqual(expectedInitialSectionProbability, calculatorInput.InitialSectionProbability);
                Assert.AreEqual(furtherAnalysisType, calculatorInput.FurtherAnalysisType);
                Assert.AreEqual(refinedSectionProbability, calculatorInput.RefinedSectionProbability);
            }
        }
Пример #2
0
        public void MaximumAllowableFloodingProbability_SignalFloodingProbabilityBiggerThanMaximumAllowableFloodingProbability_ThrowsArgumentOutOfRangeException()
        {
            // Setup
            const double probability = 1.0 / 30000;
            const double newMaximumAllowableFloodingProbability = 1.0 / 1000000;
            var          failureMechanismContribution           = new FailureMechanismContribution(probability, probability);

            // Call
            void Call() => failureMechanismContribution.MaximumAllowableFloodingProbability = newMaximumAllowableFloodingProbability;

            // Assert
            const string expectedMessage = "De omgevingswaarde moet gelijk zijn aan of groter zijn dan de signaleringsparameter.";
            var          exception       = Assert.Throws <ArgumentOutOfRangeException>(Call);

            StringAssert.StartsWith(expectedMessage, exception.Message);
            Assert.AreEqual(newMaximumAllowableFloodingProbability, exception.ActualValue);
        }
        /// <summary>
        /// Creates a <see cref="AssessmentSectionEntity"/> based on the information of the <see cref="AssessmentSection"/>.
        /// </summary>
        /// <param name="section">The section to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="AssessmentSectionEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static AssessmentSectionEntity Create(this AssessmentSection section, PersistenceRegistry registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            FailureMechanismContribution contribution = section.FailureMechanismContribution;
            var entity = new AssessmentSectionEntity
            {
                Id          = section.Id.DeepClone(),
                Name        = section.Name.DeepClone(),
                Composition = Convert.ToByte(section.Composition),
                Comments    = section.Comments.Body.DeepClone(),
                MaximumAllowableFloodingProbability = contribution.MaximumAllowableFloodingProbability,
                SignalFloodingProbability           = contribution.SignalFloodingProbability,
                NormativeProbabilityType            = Convert.ToByte(contribution.NormativeProbabilityType)
            };

            AddEntityForHydraulicDatabase(section.HydraulicBoundaryDatabase, entity, registry);
            AddHydraulicLocationCalculationEntities(section, entity, registry);
            AddHydraulicLocationCalculationForTargetProbabilityCollectionEntities(section, entity, registry);
            AddEntityForReferenceLine(section, entity);

            entity.BackgroundDataEntities.Add(section.BackgroundData.Create());

            entity.FailureMechanismEntities.Add(section.Piping.Create(registry));
            entity.FailureMechanismEntities.Add(section.GrassCoverErosionInwards.Create(registry));
            entity.FailureMechanismEntities.Add(section.HeightStructures.Create(registry));
            entity.FailureMechanismEntities.Add(section.WaterPressureAsphaltCover.Create(registry));
            entity.FailureMechanismEntities.Add(section.ClosingStructures.Create(registry));
            entity.FailureMechanismEntities.Add(section.MacroStabilityInwards.Create(registry));
            entity.FailureMechanismEntities.Add(section.WaveImpactAsphaltCover.Create(registry));
            entity.FailureMechanismEntities.Add(section.GrassCoverErosionOutwards.Create(registry));
            entity.FailureMechanismEntities.Add(section.GrassCoverSlipOffInwards.Create(registry));
            entity.FailureMechanismEntities.Add(section.GrassCoverSlipOffOutwards.Create(registry));
            entity.FailureMechanismEntities.Add(section.Microstability.Create(registry));
            entity.FailureMechanismEntities.Add(section.PipingStructure.Create(registry));
            entity.FailureMechanismEntities.Add(section.StabilityStoneCover.Create(registry));
            entity.FailureMechanismEntities.Add(section.DuneErosion.Create(registry));
            entity.FailureMechanismEntities.Add(section.StabilityPointStructures.Create(registry));

            AddSpecificFailureMechanismEntities(section, entity, registry);

            return(entity);
        }
        public void AssembleSection_WithInput_SetsInputOnCalculator()
        {
            // Setup
            var random = new Random(21);

            FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
            var sectionResult = new AdoptableWithProfileProbabilityFailureMechanismSectionResult(section)
            {
                IsRelevant = random.NextBoolean(),
                InitialFailureMechanismResultType = AdoptableInitialFailureMechanismResultType.Manual,
                ManualInitialFailureMechanismResultProfileProbability = random.NextDouble(),
                ManualInitialFailureMechanismResultSectionProbability = random.NextDouble(),
                FurtherAnalysisType       = random.NextEnumValue <FailureMechanismSectionResultFurtherAnalysisType>(),
                ProbabilityRefinementType = ProbabilityRefinementType.Both,
                RefinedProfileProbability = random.NextDouble(),
                RefinedSectionProbability = random.NextDouble()
            };

            var failureMechanism  = new MacroStabilityInwardsFailureMechanism();
            var assessmentSection = new AssessmentSectionStub();

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;

                // Call
                MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleSection(sectionResult, failureMechanism, assessmentSection);

                // Assert
                FailureMechanismSectionWithProfileProbabilityAssemblyInput calculatorInput = calculator.FailureMechanismSectionWithProfileProbabilityAssemblyInput;
                FailureMechanismContribution failureMechanismContribution = assessmentSection.FailureMechanismContribution;
                Assert.AreEqual(failureMechanismContribution.SignalFloodingProbability, calculatorInput.SignalFloodingProbability);
                Assert.AreEqual(failureMechanismContribution.MaximumAllowableFloodingProbability, calculatorInput.MaximumAllowableFloodingProbability);

                Assert.AreEqual(sectionResult.IsRelevant, calculatorInput.IsRelevant);
                Assert.IsTrue(calculatorInput.HasProbabilitySpecified);

                Assert.AreEqual(sectionResult.ManualInitialFailureMechanismResultProfileProbability, calculatorInput.InitialProfileProbability);
                Assert.AreEqual(sectionResult.ManualInitialFailureMechanismResultSectionProbability, calculatorInput.InitialSectionProbability);
                Assert.AreEqual(sectionResult.FurtherAnalysisType, calculatorInput.FurtherAnalysisType);
                Assert.AreEqual(sectionResult.RefinedProfileProbability, calculatorInput.RefinedProfileProbability);
                Assert.AreEqual(sectionResult.RefinedSectionProbability, calculatorInput.RefinedSectionProbability);
            }
        }
        public void GivenDataModelWithUnmatchableTargetProbabilities_WhenImporting_ThenLogMessageAndContinueImport(
            FailureMechanismContribution failureMechanismContribution,
            IEnumerable <HydraulicBoundaryLocationCalculationsForTargetProbability> calculationsForTargetProbabilities)
        {
            // Setup
            string filePath = Path.Combine(path, "validConfigurationFullCalculation.xml");

            var calculationGroup          = new CalculationGroup();
            var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "Locatie", 10, 20);
            var foreshoreProfile          = new ForeshoreProfile(new Point2D(0, 0), new[]
            {
                new Point2D(0, 0),
                new Point2D(1, 1),
                new Point2D(2, 2)
            }, new BreakWater(BreakWaterType.Caisson, 0), new ForeshoreProfile.ConstructionProperties
            {
                Id   = "Voorlandprofiel",
                Name = "VoorlandProfielName"
            });

            var importer = new TestWaveConditionsCalculationConfigurationImporter(
                filePath,
                calculationGroup,
                new[]
            {
                hydraulicBoundaryLocation
            },
                new[]
            {
                foreshoreProfile
            },
                failureMechanismContribution,
                calculationsForTargetProbabilities);

            // Call
            var    successful = false;
            Action call       = () => successful = importer.Import();

            // Assert
            const string expectedMessage = "De doelkans '0.01' kan niet worden gevonden 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);
        }
        /// <summary>
        /// Creates a new instance of <see cref="AssessmentSectionAssemblyGroupsView"/>.
        /// </summary>
        /// <param name="failureMechanismContribution">The failure mechanism contribution belonging to the view.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="failureMechanismContribution"/>
        /// is <c>null</c>.</exception>
        public AssessmentSectionAssemblyGroupsView(FailureMechanismContribution failureMechanismContribution)
        {
            if (failureMechanismContribution == null)
            {
                throw new ArgumentNullException(nameof(failureMechanismContribution));
            }

            InitializeComponent();

            failureMechanismContributionObserver = new Observer(UpdateTableData)
            {
                Observable = failureMechanismContribution
            };

            FailureMechanismContribution = failureMechanismContribution;

            UpdateTableData();
        }
Пример #7
0
        public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            var mocks = new MockRepository();
            var failureMechanismContributionNormChangeHandler = mocks.Stub <IFailureMechanismContributionNormChangeHandler>();

            mocks.ReplayAll();

            FailureMechanismContribution failureMechanismContribution = FailureMechanismContributionTestFactory.CreateFailureMechanismContribution();

            // Call
            var properties = new NormProperties(failureMechanismContribution, failureMechanismContributionNormChangeHandler);

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(3, dynamicProperties.Count);

            const string expectedCategory = "Algemeen";

            PropertyDescriptor maximumAllowableFloodingProbabilityProperty = dynamicProperties[0];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(maximumAllowableFloodingProbabilityProperty,
                                                                            expectedCategory,
                                                                            "Omgevingswaarde [1/jaar]",
                                                                            "De maximale toelaatbare overstromingskans van het traject.");

            PropertyDescriptor signalFloodingProbabilityProperty = dynamicProperties[1];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(signalFloodingProbabilityProperty,
                                                                            expectedCategory,
                                                                            "Signaleringsparameter [1/jaar]",
                                                                            "De overstromingskans voor de signalering over de veiligheid van het traject.");

            PropertyDescriptor normativeProbabilityTypeProperty = dynamicProperties[2];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(normativeProbabilityTypeProperty,
                                                                            expectedCategory,
                                                                            "Rekenwaarde voor waterstanden",
                                                                            "De doelkans die wordt gebruikt om de lokale waterstand te bepalen voor de semi-probabilistische toets voor 'Piping' en 'Macrostabiliteit binnenwaarts'.");

            mocks.VerifyAll();
        }
Пример #8
0
        public void GetProperties_WithData_ReturnExpectedValues()
        {
            // Setup
            var mocks = new MockRepository();
            var failureMechanismContributionNormChangeHandler = mocks.Stub <IFailureMechanismContributionNormChangeHandler>();

            mocks.ReplayAll();

            FailureMechanismContribution failureMechanismContribution = FailureMechanismContributionTestFactory.CreateFailureMechanismContribution();

            // Call
            var properties = new NormProperties(failureMechanismContribution, failureMechanismContributionNormChangeHandler);

            // Assert
            Assert.AreEqual(failureMechanismContribution.MaximumAllowableFloodingProbability, properties.MaximumAllowableFloodingProbability);
            Assert.AreEqual(failureMechanismContribution.SignalFloodingProbability, properties.SignalFloodingProbability);
            Assert.AreEqual(failureMechanismContribution.NormativeProbabilityType, properties.NormativeProbabilityType);
            mocks.VerifyAll();
        }
Пример #9
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            FailureMechanismContribution contribution = FailureMechanismContributionTestFactory.CreateFailureMechanismContribution();

            // Call
            var context = new NormContext(contribution, assessmentSection);

            // Assert
            Assert.IsInstanceOf <ObservableWrappedObjectContextBase <FailureMechanismContribution> >(context);
            Assert.AreSame(contribution, context.WrappedData);
            Assert.AreSame(assessmentSection, context.AssessmentSection);
            mocks.VerifyAll();
        }
Пример #10
0
        private AssessmentSectionAssemblyGroupProperties[] GetAssessmentSectionAssemblyGroups()
        {
            FailureMechanismContribution contribution = data.FailureMechanismContribution;

            AssessmentSectionAssemblyGroupProperties[] dataToSet;

            try
            {
                dataToSet = AssessmentSectionAssemblyGroupBoundariesFactory.CreateAssessmentSectionAssemblyGroupBoundaries(contribution.SignalFloodingProbability, contribution.MaximumAllowableFloodingProbability)
                            .Select(assemblyGroupBoundaries => new AssessmentSectionAssemblyGroupProperties(assemblyGroupBoundaries))
                            .ToArray();
            }
            catch (AssemblyException)
            {
                dataToSet = Array.Empty <AssessmentSectionAssemblyGroupProperties>();
            }

            return(dataToSet);
        }
        public void GivenViewWithFailureMechanismContribution_WhenFailureMechanismContributionUpdated_ThenDataTableUpdated()
        {
            // Given
            var random = new Random(21);

            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            FailureMechanismContribution failureMechanismContribution = FailureMechanismContributionTestFactory.CreateFailureMechanismContribution();

            failureMechanismContribution.Attach(observer);

            using (new AssemblyToolCalculatorFactoryConfig())
                using (var view = new AssessmentSectionAssemblyGroupsView(failureMechanismContribution))
                {
                    var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                    AssessmentSectionAssemblyGroupBoundariesCalculatorStub calculator = calculatorFactory.LastCreatedAssessmentSectionAssemblyGroupBoundariesCalculator;

                    AssemblyGroupsTable <AssessmentSectionAssemblyGroup> groupsTable = GetCategoriesTable(view);

                    // Precondition
                    Assert.AreEqual(calculator.AssessmentSectionAssemblyGroupBoundariesOutput.Count(), groupsTable.Rows.Count);

                    // When
                    var newOutput = new[]
                    {
                        new AssessmentSectionAssemblyGroupBoundaries(random.NextDouble(),
                                                                     random.NextDouble(),
                                                                     random.NextEnumValue <AssessmentSectionAssemblyGroup>())
                    };
                    calculator.AssessmentSectionAssemblyGroupBoundariesOutput = newOutput;
                    failureMechanismContribution.NotifyObservers();

                    // Then
                    Assert.AreEqual(newOutput.Length, groupsTable.Rows.Count);
                }

            mocks.VerifyAll();
        }
Пример #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssessmentSection"/> class.
        /// </summary>
        /// <param name="composition">The composition of the assessment section, e.g. what
        /// type of elements can be found within the assessment section.</param>
        /// <param name="maximumAllowableFloodingProbability">The maximum allowable flooding probability of the assessment section.</param>
        /// <param name="signalFloodingProbability">The signal flooding probability of the assessment section.</param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when:
        /// <list type="bullet">
        /// <item><paramref name="maximumAllowableFloodingProbability"/> is not in the interval [0.000001, 0.1] or is <see cref="double.NaN"/>;</item>
        /// <item><paramref name="signalFloodingProbability"/> is not in the interval [0.000001, 0.1] or is <see cref="double.NaN"/>;</item>
        /// <item>The <paramref name="signalFloodingProbability"/> is larger than <paramref name="maximumAllowableFloodingProbability"/>.</item>
        /// </list>
        /// </exception>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="composition"/>
        /// is not a valid enum value of <see cref="AssessmentSectionComposition"/>.</exception>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="composition"/>
        /// is not supported.</exception>
        public AssessmentSection(AssessmentSectionComposition composition,
                                 double maximumAllowableFloodingProbability = defaultFloodingProbability,
                                 double signalFloodingProbability           = defaultFloodingProbability)
        {
            Name     = Resources.AssessmentSection_DisplayName;
            Comments = new Comment();

            BackgroundData = new BackgroundData(new WellKnownBackgroundDataConfiguration(defaultWellKnownTileSource))
            {
                Name = defaultWellKnownTileSource.GetDisplayName()
            };

            ReferenceLine = new ReferenceLine();

            HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();

            SpecificFailureMechanisms = new ObservableList <SpecificFailureMechanism>();
            waterLevelCalculationsForSignalFloodingProbability           = new ObservableList <HydraulicBoundaryLocationCalculation>();
            waterLevelCalculationsForMaximumAllowableFloodingProbability = new ObservableList <HydraulicBoundaryLocationCalculation>();
            WaterLevelCalculationsForUserDefinedTargetProbabilities      = new ObservableList <HydraulicBoundaryLocationCalculationsForTargetProbability>();
            WaveHeightCalculationsForUserDefinedTargetProbabilities      = new ObservableList <HydraulicBoundaryLocationCalculationsForTargetProbability>();

            Piping = new PipingFailureMechanism();
            GrassCoverErosionInwards  = new GrassCoverErosionInwardsFailureMechanism();
            MacroStabilityInwards     = new MacroStabilityInwardsFailureMechanism();
            Microstability            = new MicrostabilityFailureMechanism();
            StabilityStoneCover       = new StabilityStoneCoverFailureMechanism();
            WaveImpactAsphaltCover    = new WaveImpactAsphaltCoverFailureMechanism();
            WaterPressureAsphaltCover = new WaterPressureAsphaltCoverFailureMechanism();
            GrassCoverErosionOutwards = new GrassCoverErosionOutwardsFailureMechanism();
            GrassCoverSlipOffOutwards = new GrassCoverSlipOffOutwardsFailureMechanism();
            GrassCoverSlipOffInwards  = new GrassCoverSlipOffInwardsFailureMechanism();
            HeightStructures          = new HeightStructuresFailureMechanism();
            ClosingStructures         = new ClosingStructuresFailureMechanism();
            StabilityPointStructures  = new StabilityPointStructuresFailureMechanism();
            PipingStructure           = new PipingStructureFailureMechanism();
            DuneErosion = new DuneErosionFailureMechanism();

            FailureMechanismContribution = new FailureMechanismContribution(maximumAllowableFloodingProbability, signalFloodingProbability);
            ChangeComposition(composition);
        }
        public void Constructor_WithFailureMechanismContribution_CreatesViewAndTableWithData()
        {
            // Setup
            FailureMechanismContribution failureMechanismContribution = FailureMechanismContributionTestFactory.CreateFailureMechanismContribution();

            // Call
            using (new AssemblyToolCalculatorFactoryConfig())
                using (var view = new AssessmentSectionAssemblyGroupsView(failureMechanismContribution))
                {
                    // Assert
                    Assert.IsInstanceOf <UserControl>(view);
                    Assert.IsInstanceOf <IView>(view);
                    Assert.IsNull(view.Data);
                    Assert.AreEqual(1, view.Controls.Count);
                    Assert.AreSame(failureMechanismContribution, view.FailureMechanismContribution);

                    AssemblyGroupsTable <AssessmentSectionAssemblyGroup> tableControl = GetCategoriesTable(view);
                    Assert.AreEqual(DockStyle.Fill, tableControl.Dock);

                    var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                    AssessmentSectionAssemblyGroupBoundariesCalculatorStub calculator = calculatorFactory.LastCreatedAssessmentSectionAssemblyGroupBoundariesCalculator;
                    Assert.AreEqual(calculator.AssessmentSectionAssemblyGroupBoundariesOutput.Count(), tableControl.Rows.Count);
                }
        }
Пример #14
0
        public void GivenMapLayerWithHydraulicBoundaryLocationsData_WhenFailureMechanismContributionUpdatedAndNotified_ThenMapDataUpdated()
        {
            // Given
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            var assessmentSection = new AssessmentSectionStub();

            assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
            {
                new HydraulicBoundaryLocation(1, "test1", 1.0, 2.0)
            });

            using (var mapLayer = new HydraulicBoundaryLocationsMapLayer(assessmentSection))
            {
                mapLayer.MapData.Attach(observer);

                // Precondition
                MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection, mapLayer.MapData);

                // When
                var random = new Random(21);
                FailureMechanismContribution contribution = assessmentSection.FailureMechanismContribution;
                contribution.MaximumAllowableFloodingProbability = random.NextDouble(0.000001, 0.1);
                contribution.SignalFloodingProbability           = contribution.MaximumAllowableFloodingProbability - 0.000001;
                contribution.NotifyObservers();

                // Then
                MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection, mapLayer.MapData);
            }

            mocks.VerifyAll();
        }
 /// <inheritdoc />
 /// <summary>
 /// Creates a new instance of <see cref="GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationImporter"/>.
 /// </summary>
 public GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationImporter(string xmlFilePath,
                                                                                CalculationGroup importTarget,
                                                                                IEnumerable <HydraulicBoundaryLocation> hydraulicBoundaryLocations,
                                                                                IEnumerable <ForeshoreProfile> foreshoreProfiles,
                                                                                FailureMechanismContribution failureMechanismContribution,
                                                                                IEnumerable <HydraulicBoundaryLocationCalculationsForTargetProbability> calculationsForTargetProbabilities)
     : base(xmlFilePath, importTarget, hydraulicBoundaryLocations, foreshoreProfiles, failureMechanismContribution, calculationsForTargetProbabilities)
 {
 }
        public void Import_ValidConfigurationWithValidData_DataAddedToModel(FailureMechanismContribution failureMechanismContribution,
                                                                            HydraulicBoundaryLocationCalculationsForTargetProbability calculationsForTargetProbability,
                                                                            WaveConditionsInputWaterLevelType expectedWaterLevelType)
        {
            // Setup
            string filePath = Path.Combine(path, "validConfigurationFullCalculation.xml");

            var calculationGroup          = new CalculationGroup();
            var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "Locatie", 10, 20);
            var foreshoreProfile          = new ForeshoreProfile(new Point2D(0, 0), new[]
            {
                new Point2D(0, 0),
                new Point2D(1, 1),
                new Point2D(2, 2)
            }, new BreakWater(BreakWaterType.Caisson, 0), new ForeshoreProfile.ConstructionProperties
            {
                Id   = "Voorlandprofiel",
                Name = "VoorlandProfielName"
            });

            var importer = new TestWaveConditionsCalculationConfigurationImporter(
                filePath,
                calculationGroup,
                new[]
            {
                hydraulicBoundaryLocation
            },
                new[]
            {
                foreshoreProfile
            },
                failureMechanismContribution,
                new[]
            {
                calculationsForTargetProbability
            });

            // 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 TestTargetTestWaveConditionsCalculation
            {
                Name            = "Berekening 1",
                InputParameters =
                {
                    HydraulicBoundaryLocation     = hydraulicBoundaryLocation,
                    CalculationsTargetProbability = expectedWaterLevelType == WaveConditionsInputWaterLevelType.UserDefinedTargetProbability
                                                        ? calculationsForTargetProbability
                                                        : null,
                    WaterLevelType           = expectedWaterLevelType,
                    UpperBoundaryRevetment   = (RoundedDouble)10,
                    LowerBoundaryRevetment   = (RoundedDouble)2,
                    UpperBoundaryWaterLevels = (RoundedDouble)9,
                    LowerBoundaryWaterLevels = (RoundedDouble)4,
                    StepSize         = WaveConditionsInputStepSize.Half,
                    ForeshoreProfile = foreshoreProfile,
                    Orientation      = (RoundedDouble)5.5,
                    UseForeshore     = false,
                    UseBreakWater    = true,
                    BreakWater       =
                    {
                        Height = (RoundedDouble)6.6,
                        Type   = BreakWaterType.Caisson
                    }
                }
            };

            Assert.AreEqual(1, calculationGroup.Children.Count);
            AssertWaveConditionsCalculation(expectedCalculation, (ICalculation <WaveConditionsInput>)calculationGroup.Children[0]);
        }
Пример #17
0
        public void AssembleSectionAdoptableWithProfileProbability_WithInputAndUseLengthEffectTrue_SetsInputOnCalculator(
            AdoptableInitialFailureMechanismResultType initialFailureMechanismResultType, bool expectedHasProbabilitySpecified)
        {
            // Setup
            var    random     = new Random(21);
            bool   isRelevant = random.NextBoolean();
            double manualInitialProfileProbability             = random.NextDouble();
            double manualInitialSectionProbability             = random.NextDouble();
            double calculatedStrategySectionProbability        = random.NextDouble();
            double calculatedStrategyProfileSectionProbability = random.NextDouble();
            var    furtherAnalysisType             = random.NextEnumValue <FailureMechanismSectionResultFurtherAnalysisType>();
            double manualRefinedSectionProbability = random.NextDouble();
            double manualRefinedProfileProbability = random.NextDouble();

            var  mocks             = new MockRepository();
            var  calculateStrategy = mocks.StrictMock <IFailureMechanismSectionResultCalculateProbabilityStrategy>();
            bool isInitialFailureMechanismResultTypeAdopt = IsInitialFailureMechanismResultTypeAdopt(initialFailureMechanismResultType);

            if (isInitialFailureMechanismResultTypeAdopt)
            {
                calculateStrategy.Expect(cs => cs.CalculateProfileProbability())
                .Return(calculatedStrategyProfileSectionProbability);
                calculateStrategy.Expect(cs => cs.CalculateSectionProbability())
                .Return(calculatedStrategySectionProbability);
            }

            mocks.ReplayAll();

            var assessmentSection = new AssessmentSectionStub();

            var sectionResult = new AdoptableWithProfileProbabilityFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
            {
                IsRelevant = isRelevant,
                InitialFailureMechanismResultType = initialFailureMechanismResultType,
                ManualInitialFailureMechanismResultProfileProbability = manualInitialProfileProbability,
                ManualInitialFailureMechanismResultSectionProbability = manualInitialSectionProbability,
                FurtherAnalysisType       = furtherAnalysisType,
                ProbabilityRefinementType = ProbabilityRefinementType.Both,
                RefinedProfileProbability = manualRefinedProfileProbability,
                RefinedSectionProbability = manualRefinedSectionProbability
            };

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;

                // Call
                FailureMechanismSectionAssemblyResultFactory.AssembleSection(
                    sectionResult, assessmentSection, calculateStrategy, true, random.NextDouble());

                // Assert
                FailureMechanismSectionWithProfileProbabilityAssemblyInput calculatorInput = calculator.FailureMechanismSectionWithProfileProbabilityAssemblyInput;
                FailureMechanismContribution failureMechanismContribution = assessmentSection.FailureMechanismContribution;
                Assert.AreEqual(failureMechanismContribution.SignalFloodingProbability, calculatorInput.SignalFloodingProbability);
                Assert.AreEqual(failureMechanismContribution.MaximumAllowableFloodingProbability, calculatorInput.MaximumAllowableFloodingProbability);

                Assert.AreEqual(isRelevant, calculatorInput.IsRelevant);
                Assert.AreEqual(expectedHasProbabilitySpecified, calculatorInput.HasProbabilitySpecified);

                double expectedInitialProfileProbability = isInitialFailureMechanismResultTypeAdopt
                                                               ? calculatedStrategyProfileSectionProbability
                                                               : manualInitialProfileProbability;
                Assert.AreEqual(expectedInitialProfileProbability, calculatorInput.InitialProfileProbability);
                double expectedInitialSectionProbability = isInitialFailureMechanismResultTypeAdopt
                                                               ? calculatedStrategySectionProbability
                                                               : manualInitialSectionProbability;
                Assert.AreEqual(expectedInitialSectionProbability, calculatorInput.InitialSectionProbability);
                Assert.AreEqual(furtherAnalysisType, calculatorInput.FurtherAnalysisType);
                Assert.AreEqual(manualRefinedProfileProbability, calculatorInput.RefinedProfileProbability);
                Assert.AreEqual(manualRefinedSectionProbability, calculatorInput.RefinedSectionProbability);
            }
        }