Exemple #1
0
        public void GenerateCalculations_Always_SetsCorrectCalculations()
        {
            // Setup
            var calculationGroup = new CalculationGroup();

            DikeProfile dikeProfile1 = DikeProfileTestFactory.CreateDikeProfile(new Point2D(0.0, 0.0), "profiel 1");
            DikeProfile dikeProfile2 = DikeProfileTestFactory.CreateDikeProfile(new Point2D(0.0, 0.0), "profiel 2");

            var failureMechanismContribution = new FailureMechanismContribution(0.01, 0.001);

            // Call
            GrassCoverErosionInwardsCalculationConfigurationHelper.GenerateCalculations(
                calculationGroup, new[]
            {
                dikeProfile1,
                dikeProfile2
            }, failureMechanismContribution);

            // Assert
            Assert.AreEqual(2, calculationGroup.Children.Count);

            var calculation1 = (GrassCoverErosionInwardsCalculationScenario)calculationGroup.Children.First();

            Assert.AreEqual("name", calculation1.Name);
            Assert.AreEqual(dikeProfile1, calculation1.InputParameters.DikeProfile);
            Assert.AreEqual(failureMechanismContribution.NormativeProbability, calculation1.InputParameters.DikeHeightTargetProbability);
            Assert.AreEqual(failureMechanismContribution.NormativeProbability, calculation1.InputParameters.OvertoppingRateTargetProbability);

            var calculation2 = (GrassCoverErosionInwardsCalculationScenario)calculationGroup.Children.Last();

            Assert.AreEqual("name (1)", calculation2.Name);
            Assert.AreEqual(dikeProfile2, calculation2.InputParameters.DikeProfile);
            Assert.AreEqual(failureMechanismContribution.NormativeProbability, calculation2.InputParameters.DikeHeightTargetProbability);
            Assert.AreEqual(failureMechanismContribution.NormativeProbability, calculation2.InputParameters.OvertoppingRateTargetProbability);
        }
Exemple #2
0
        public void GenerateCalculations_DikeProfilesNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => GrassCoverErosionInwardsCalculationConfigurationHelper.GenerateCalculations(
                new CalculationGroup(), null, new FailureMechanismContribution(0.01, 0.001));

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("dikeProfiles", exception.ParamName);
        }
Exemple #3
0
        public void GenerateCalculations_FailureMechanismContributionNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => GrassCoverErosionInwardsCalculationConfigurationHelper.GenerateCalculations(
                new CalculationGroup(), Enumerable.Empty <DikeProfile>(), null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("failureMechanismContribution", exception.ParamName);
        }
        protected override void GenerateCalculations()
        {
            var calculationGroup = (CalculationGroup)Data;

            using (var dialog = new GrassCoverErosionInwardsDikeProfileSelectionDialog(Parent, FailureMechanism.DikeProfiles))
            {
                dialog.ShowDialog();

                if (dialog.SelectedItems.Any())
                {
                    GrassCoverErosionInwardsCalculationConfigurationHelper.GenerateCalculations(
                        calculationGroup, dialog.SelectedItems, AssessmentSection.FailureMechanismContribution);
                    calculationGroup.NotifyObservers();
                }
            }
        }