Esempio n. 1
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocksRepository   = new MockRepository();
            var assessmentSection = mocksRepository.Stub <IAssessmentSection>();

            mocksRepository.ReplayAll();

            var calculation      = new GrassCoverErosionInwardsCalculationScenario();
            var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
            var parent           = new CalculationGroup();

            // Call
            var context = new GrassCoverErosionInwardsCalculationScenarioContext(calculation, parent, failureMechanism, assessmentSection);

            // Assert
            Assert.IsInstanceOf <GrassCoverErosionInwardsContext <GrassCoverErosionInwardsCalculationScenario> >(context);
            Assert.IsInstanceOf <ICalculationContext <GrassCoverErosionInwardsCalculationScenario, GrassCoverErosionInwardsFailureMechanism> >(context);
            Assert.AreSame(calculation, context.WrappedData);
            Assert.AreSame(parent, context.Parent);
            Assert.AreSame(failureMechanism, context.FailureMechanism);
            Assert.AreSame(assessmentSection, context.AssessmentSection);

            mocksRepository.VerifyAll();
        }
Esempio n. 2
0
 public DerivedGrassCoverErosionInwardsCalculationScenarioContext(GrassCoverErosionInwardsCalculationScenario calculation,
                                                                  CalculationGroup parent,
                                                                  GrassCoverErosionInwardsFailureMechanism failureMechanism,
                                                                  IAssessmentSection assessmentSection)
     : base(calculation, parent, failureMechanism, assessmentSection)
 {
 }
Esempio n. 3
0
        public void GetInitialFailureMechanismResultProbability_MultipleScenarios_ReturnsValueBasedOnRelevantScenarios()
        {
            // Setup
            FailureMechanismSection section   = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
            var failureMechanismSectionResult = new AdoptableWithProfileProbabilityFailureMechanismSectionResult(section);

            GrassCoverErosionInwardsCalculationScenario calculationScenario1 = GrassCoverErosionInwardsCalculationScenarioTestFactory.CreateGrassCoverErosionInwardsCalculationScenario(section);
            GrassCoverErosionInwardsCalculationScenario calculationScenario2 = GrassCoverErosionInwardsCalculationScenarioTestFactory.CreateGrassCoverErosionInwardsCalculationScenario(section);
            GrassCoverErosionInwardsCalculationScenario calculationScenario3 = GrassCoverErosionInwardsCalculationScenarioTestFactory.CreateGrassCoverErosionInwardsCalculationScenario(section);

            calculationScenario1.IsRelevant   = true;
            calculationScenario1.Contribution = (RoundedDouble)0.2111;
            calculationScenario1.Output       = new GrassCoverErosionInwardsOutput(new TestOvertoppingOutput(1.1), null, null);

            calculationScenario2.IsRelevant   = true;
            calculationScenario2.Contribution = (RoundedDouble)0.7889;
            calculationScenario1.Output       = new GrassCoverErosionInwardsOutput(new TestOvertoppingOutput(2.2), null, null);

            calculationScenario3.IsRelevant = false;

            GrassCoverErosionInwardsCalculationScenario[] calculationScenarios =
            {
                calculationScenario1,
                calculationScenario2,
                calculationScenario3
            };

            // Call
            double initialFailureMechanismResultProbability = failureMechanismSectionResult.GetInitialFailureMechanismResultProbability(calculationScenarios);

            // Assert
            Assert.AreEqual(0.3973850177700996, initialFailureMechanismResultProbability);
        }
Esempio n. 4
0
        public void Create_StringPropertiesDoNotShareReference()
        {
            // Setup
            const string name        = "A";
            const string comment     = "B";
            var          calculation = new GrassCoverErosionInwardsCalculationScenario
            {
                Name     = name,
                Comments =
                {
                    Body = comment
                }
            };

            var registry = new PersistenceRegistry();

            // Call
            GrassCoverErosionInwardsCalculationEntity entity = calculation.Create(registry, 0);

            // Assert
            Assert.AreNotSame(name, entity.Name,
                              "To create stable binary representations/fingerprints, it's really important that strings are not shared.");
            Assert.AreEqual(name, entity.Name);

            Assert.AreNotSame(comment, entity.Comments,
                              "To create stable binary representations/fingerprints, it's really important that strings are not shared.");
            Assert.AreEqual(comment, entity.Comments);
        }
Esempio n. 5
0
        public void Create_NaNParameters_EntityWithNullFields()
        {
            // Setup
            var calculation = new GrassCoverErosionInwardsCalculationScenario
            {
                InputParameters =
                {
                    Orientation      = RoundedDouble.NaN,
                    CriticalFlowRate =
                    {
                        Mean              = RoundedDouble.NaN,
                        StandardDeviation = RoundedDouble.NaN
                    },
                    DikeHeight = RoundedDouble.NaN,
                    BreakWater =
                    {
                        Height            = RoundedDouble.NaN
                    }
                }
            };
            var registry = new PersistenceRegistry();

            // Call
            GrassCoverErosionInwardsCalculationEntity entity = calculation.Create(registry, 0);

            // Assert
            Assert.IsNull(entity.Orientation);
            Assert.IsNull(entity.CriticalFlowRateMean);
            Assert.IsNull(entity.CriticalFlowRateStandardDeviation);
            Assert.IsNull(entity.DikeHeight);
            Assert.IsNull(entity.BreakWaterHeight);
        }
Esempio n. 6
0
        public void Read_ValidEntityWithUnreadDikeProfileEntity_ReturnCalculationWithNewDikeProfile()
        {
            // Setup
            var dikeProfileEntity = new DikeProfileEntity
            {
                Id = "a",
                DikeGeometryXml = new RoughnessPointCollectionXmlSerializer().ToXml(new RoughnessPoint[0]),
                ForeshoreXml    = new Point2DCollectionXmlSerializer().ToXml(new Point2D[0])
            };
            var entity = new GrassCoverErosionInwardsCalculationEntity
            {
                DikeProfileEntity                = dikeProfileEntity,
                ScenarioContribution             = 0,
                DikeHeightTargetProbability      = 0.01,
                OvertoppingRateTargetProbability = 0.02
            };

            var collector = new ReadConversionCollector();

            // Call
            GrassCoverErosionInwardsCalculationScenario calculation = entity.Read(collector);

            // Assert
            Assert.IsNotNull(calculation.InputParameters.DikeProfile);
            Assert.IsTrue(collector.Contains(dikeProfileEntity));
        }
Esempio n. 7
0
        public void CloseForData_ViewCorrespondingToRemovedCalculationContext_ReturnsTrue()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var calculation        = new GrassCoverErosionInwardsCalculationScenario();
            var calculationContext = new GrassCoverErosionInwardsCalculationScenarioContext(calculation,
                                                                                            new CalculationGroup(),
                                                                                            new GrassCoverErosionInwardsFailureMechanism(),
                                                                                            assessmentSection);

            using (var view = new GrassCoverErosionInwardsInputView
            {
                Data = calculation
            })
            {
                // Call
                bool closeForData = info.CloseForData(view, calculationContext);

                // Assert
                Assert.IsTrue(closeForData);
                mocks.VerifyAll();
            }
        }
Esempio n. 8
0
        private static void AssertCalculationScenario(GrassCoverErosionInwardsCalculationScenario expectedCalculation, GrassCoverErosionInwardsCalculationScenario actualCalculation)
        {
            Assert.AreEqual(expectedCalculation.Name, actualCalculation.Name);
            Assert.AreEqual(expectedCalculation.IsRelevant, actualCalculation.IsRelevant);
            Assert.AreEqual(expectedCalculation.Contribution, actualCalculation.Contribution);

            GrassCoverErosionInwardsInput expectedInput = expectedCalculation.InputParameters;
            GrassCoverErosionInwardsInput actualInput   = actualCalculation.InputParameters;

            Assert.AreSame(expectedInput.HydraulicBoundaryLocation, actualInput.HydraulicBoundaryLocation);
            Assert.AreEqual(expectedInput.Orientation, actualInput.Orientation);
            Assert.AreSame(expectedInput.DikeProfile, actualInput.DikeProfile);
            Assert.AreEqual(expectedInput.DikeHeight, actualInput.DikeHeight);
            Assert.AreEqual(expectedInput.UseForeshore, actualInput.UseForeshore);
            Assert.AreEqual(expectedInput.UseBreakWater, actualInput.UseBreakWater);
            Assert.AreEqual(expectedInput.BreakWater.Height, actualInput.BreakWater.Height);
            Assert.AreEqual(expectedInput.BreakWater.Type, actualInput.BreakWater.Type);
            DistributionAssert.AreEqual(expectedInput.CriticalFlowRate, actualInput.CriticalFlowRate);
            Assert.AreEqual(expectedInput.ShouldOvertoppingOutputIllustrationPointsBeCalculated,
                            actualInput.ShouldOvertoppingOutputIllustrationPointsBeCalculated);
            Assert.AreEqual(expectedInput.ShouldDikeHeightBeCalculated, actualInput.ShouldDikeHeightBeCalculated);
            Assert.AreEqual(expectedInput.DikeHeightTargetProbability, actualInput.DikeHeightTargetProbability);
            Assert.AreEqual(expectedInput.ShouldDikeHeightIllustrationPointsBeCalculated,
                            actualInput.ShouldDikeHeightIllustrationPointsBeCalculated);
            Assert.AreEqual(expectedInput.ShouldOvertoppingRateBeCalculated, actualInput.ShouldOvertoppingRateBeCalculated);
            Assert.AreEqual(expectedInput.OvertoppingRateTargetProbability, actualInput.OvertoppingRateTargetProbability);
            Assert.AreEqual(expectedInput.ShouldOvertoppingRateIllustrationPointsBeCalculated,
                            actualInput.ShouldOvertoppingRateIllustrationPointsBeCalculated);
        }
Esempio n. 9
0
        public void IsDikeProfileIntersectionWithReferenceLineInSection_EmptySegmentCollection_ThrowsInvalidOperationException()
        {
            // Setup
            DikeProfile dikeProfile   = DikeProfileTestFactory.CreateDikeProfile(new Point2D(0.0, 0.0));
            var         referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(new[]
            {
                new Point2D(0.0, 0.0),
                new Point2D(10.0, 0.0)
            });

            var calculation = new GrassCoverErosionInwardsCalculationScenario
            {
                InputParameters =
                {
                    DikeProfile = dikeProfile
                }
            };

            // Call
            void Call() => calculation.IsDikeProfileIntersectionWithReferenceLineInSection(Enumerable.Empty <Segment2D>());

            // Assert
            Assert.Throws <InvalidOperationException>(Call);
        }
Esempio n. 10
0
 /// <summary>
 /// Method that asserts whether <paramref name="original"/> and <paramref name="clone"/>
 /// are clones.
 /// </summary>
 /// <param name="original">The original object.</param>
 /// <param name="clone">The cloned object.</param>
 /// <exception cref="AssertionException">Thrown when <paramref name="original"/> and
 /// <paramref name="clone"/> are not clones.</exception>
 public static void AreClones(GrassCoverErosionInwardsCalculationScenario original,
                              GrassCoverErosionInwardsCalculationScenario clone)
 {
     Assert.AreEqual(original.Contribution, clone.Contribution);
     Assert.AreEqual(original.IsRelevant, clone.IsRelevant);
     AreClones((GrassCoverErosionInwardsCalculation)original, clone);
 }
        /// <summary>
        /// Configures calculations and adds them to the calculation group.
        /// </summary>
        /// <param name="calculationGroup">The calculation group.</param>
        /// <param name="dikeProfiles">The collection of dike profiles.</param>
        /// <param name="failureMechanismContribution">The <see cref="FailureMechanismContribution"/>
        /// used to get the default target probability.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static void GenerateCalculations(CalculationGroup calculationGroup, IEnumerable <DikeProfile> dikeProfiles,
                                                FailureMechanismContribution failureMechanismContribution)
        {
            if (calculationGroup == null)
            {
                throw new ArgumentNullException(nameof(calculationGroup));
            }

            if (dikeProfiles == null)
            {
                throw new ArgumentNullException(nameof(dikeProfiles));
            }

            if (failureMechanismContribution == null)
            {
                throw new ArgumentNullException(nameof(failureMechanismContribution));
            }

            foreach (DikeProfile profile in dikeProfiles)
            {
                var calculation = new GrassCoverErosionInwardsCalculationScenario
                {
                    Name            = NamingHelper.GetUniqueName(calculationGroup.Children, profile.Name, c => c.Name),
                    InputParameters =
                    {
                        DikeProfile                      = profile,
                        DikeHeightTargetProbability      = failureMechanismContribution.NormativeProbability,
                        OvertoppingRateTargetProbability = failureMechanismContribution.NormativeProbability
                    }
                };
                calculationGroup.Children.Add(calculation);
            }
        }
Esempio n. 12
0
        public void GetInitialFailureMechanismResultProbability_ScenarioWithNaNResults_ReturnsNaN()
        {
            // Setup
            FailureMechanismSection section   = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
            var failureMechanismSectionResult = new AdoptableWithProfileProbabilityFailureMechanismSectionResult(section);

            const double contribution1 = 0.2;
            const double contribution2 = 0.8;

            GrassCoverErosionInwardsCalculationScenario calculationScenario1 = GrassCoverErosionInwardsCalculationScenarioTestFactory.CreateGrassCoverErosionInwardsCalculationScenario(section);
            GrassCoverErosionInwardsCalculationScenario calculationScenario2 = GrassCoverErosionInwardsCalculationScenarioTestFactory.CreateNotCalculatedGrassCoverErosionInwardsCalculationScenario(section);

            calculationScenario1.IsRelevant   = true;
            calculationScenario1.Contribution = (RoundedDouble)contribution1;

            calculationScenario2.IsRelevant   = true;
            calculationScenario2.Contribution = (RoundedDouble)contribution2;
            calculationScenario2.Output       = new GrassCoverErosionInwardsOutput(new TestOvertoppingOutput(double.NaN), null, null);

            GrassCoverErosionInwardsCalculationScenario[] calculationScenarios =
            {
                calculationScenario1,
                calculationScenario2
            };

            // Call
            double initialFailureMechanismResultProbability = failureMechanismSectionResult.GetInitialFailureMechanismResultProbability(calculationScenarios);

            // Assert
            Assert.IsNaN(initialFailureMechanismResultProbability);
        }
Esempio n. 13
0
        public void GivenScenarioRow_WhenOutputChangedAndUpdate_ThenDerivedOutputUpdated()
        {
            // Given
            var calculation = new GrassCoverErosionInwardsCalculationScenario
            {
                Output = new TestGrassCoverErosionInwardsOutput()
            };

            var row = new GrassCoverErosionInwardsScenarioRow(calculation);

            // Precondition
            ProbabilityAssessmentOutput expectedDerivedOutput = ProbabilityAssessmentOutputFactory.Create(calculation.Output.OvertoppingOutput.Reliability);

            Assert.AreEqual(expectedDerivedOutput.Probability, row.FailureProbability);

            var random = new Random(11);

            // When
            calculation.Output = new GrassCoverErosionInwardsOutput(new TestOvertoppingOutput(random.NextDouble()), null, null);
            row.Update();

            // Then
            ProbabilityAssessmentOutput newExpectedDerivedOutput = ProbabilityAssessmentOutputFactory.Create(calculation.Output.OvertoppingOutput.Reliability);

            Assert.AreEqual(newExpectedDerivedOutput.Probability, row.FailureProbability);
        }
Esempio n. 14
0
        public void Constructor_DikeProfileWithForeshoreGeometry_CorrectColumnStates(bool useBreakWater)
        {
            // Setup
            var calculationScenario = new GrassCoverErosionInwardsCalculationScenario
            {
                InputParameters =
                {
                    DikeProfile   = DikeProfileTestFactory.CreateDikeProfile(new[]
                    {
                        new Point2D(0.0, 0.0)
                    }),
                    UseBreakWater = useBreakWater
                }
            };

            // Call
            var row = new GrassCoverErosionInwardsCalculationRow(calculationScenario, new ObservablePropertyChangeHandler(
                                                                     calculationScenario, new GrassCoverErosionInwardsInput()));

            // Assert
            IDictionary <int, DataGridViewColumnStateDefinition> columnStateDefinitions = row.ColumnStateDefinitions;

            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useBreakWaterColumnIndex], true);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterTypeColumnIndex], useBreakWater);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterHeightColumnIndex], useBreakWater);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useForeshoreColumnIndex], true);
        }
Esempio n. 15
0
        public void DikeProfile_OnChangeToNull_CorrectColumnStates()
        {
            // Setup
            var calculationScenario = new GrassCoverErosionInwardsCalculationScenario
            {
                InputParameters =
                {
                    DikeProfile = DikeProfileTestFactory.CreateDikeProfile()
                }
            };

            // Call
            var row = new GrassCoverErosionInwardsCalculationRow(calculationScenario, new ObservablePropertyChangeHandler(
                                                                     calculationScenario, new GrassCoverErosionInwardsInput()))
            {
                DikeProfile = new DataGridViewComboBoxItemWrapper <DikeProfile>(null)
            };

            // Assert
            IDictionary <int, DataGridViewColumnStateDefinition> columnStateDefinitions = row.ColumnStateDefinitions;

            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useBreakWaterColumnIndex], false);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterTypeColumnIndex], false);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterHeightColumnIndex], false);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useForeshoreColumnIndex], false);
        }
Esempio n. 16
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocks   = new MockRepository();
            var handler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            var calculationScenario = new GrassCoverErosionInwardsCalculationScenario();

            // Call
            var row = new GrassCoverErosionInwardsCalculationRow(calculationScenario, handler);

            // Asserts
            Assert.IsInstanceOf <CalculationRow <GrassCoverErosionInwardsCalculationScenario> >(row);
            Assert.IsInstanceOf <IHasColumnStateDefinitions>(row);
            Assert.AreSame(calculationScenario, row.Calculation);

            IDictionary <int, DataGridViewColumnStateDefinition> columnStateDefinitions = row.ColumnStateDefinitions;

            Assert.AreEqual(4, columnStateDefinitions.Count);

            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnStateDefinition(columnStateDefinitions, useBreakWaterColumnIndex);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnStateDefinition(columnStateDefinitions, breakWaterTypeColumnIndex);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnStateDefinition(columnStateDefinitions, breakWaterHeightColumnIndex);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnStateDefinition(columnStateDefinitions, useForeshoreColumnIndex);

            mocks.VerifyAll();
        }
Esempio n. 17
0
        private static void AssertPropertyChangeWithOrWithoutCalculationOutput(
            Action <GrassCoverErosionInwardsCalculationRow> setProperty,
            Action <GrassCoverErosionInwardsCalculationScenario> assertions,
            bool hasOutput,
            bool expectUpdates)
        {
            // Setup
            var mockRepository = new MockRepository();
            var inputObserver  = mockRepository.StrictMock <IObserver>();

            if (expectUpdates)
            {
                inputObserver.Expect(o => o.UpdateObserver());
            }

            var calculationObserver = mockRepository.StrictMock <IObserver>();

            if (expectUpdates && hasOutput)
            {
                calculationObserver.Expect(o => o.UpdateObserver());
            }

            var handler = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            GrassCoverErosionInwardsOutput assignedOutput = null;

            GrassCoverErosionInwardsCalculationScenario calculation = GrassCoverErosionInwardsCalculationScenarioTestFactory.CreateNotCalculatedGrassCoverErosionInwardsCalculationScenario(new FailureMechanismSection("Section 1", new List <Point2D>
            {
                new Point2D(0.0, 0.0)
            }));

            calculation.InputParameters.HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
            if (hasOutput)
            {
                assignedOutput = new GrassCoverErosionInwardsOutput(new TestOvertoppingOutput(0.2), null, null);
            }

            calculation.Output = assignedOutput;

            var row = new GrassCoverErosionInwardsCalculationRow(calculation, handler);

            calculation.Attach(calculationObserver);
            calculation.InputParameters.Attach(inputObserver);

            // Call
            setProperty(row);

            // Assert
            assertions(calculation);
            if (expectUpdates)
            {
                Assert.IsNull(calculation.Output);
            }
            else
            {
                Assert.AreSame(assignedOutput, calculation.Output);
            }
        }
Esempio n. 18
0
        private static void SetPropertyAndVerifyNotificationsAndOutputForCalculation(
            Action <GrassCoverErosionInwardsCalculationRow> setProperty,
            GrassCoverErosionInwardsCalculationScenario calculation)
        {
            // Setup
            var mocks      = new MockRepository();
            var observable = mocks.StrictMock <IObservable>();

            observable.Expect(o => o.NotifyObservers());
            mocks.ReplayAll();

            var handler = new SetPropertyValueAfterConfirmationParameterTester(
                new[]
            {
                observable
            });

            var row = new GrassCoverErosionInwardsCalculationRow(calculation, handler);

            // Call
            setProperty(row);

            // Assert
            Assert.IsTrue(handler.Called);
            mocks.VerifyAll();
        }
Esempio n. 19
0
        public void Import_ValidConfigurationOnlyCriticalFlowRateNoParametersSet_DataAddedToModel()
        {
            // Setup
            string filePath = Path.Combine(importerPath, "validConfigurationCriticalFlowRateNoParameters.xml");

            var          calculationGroup = new CalculationGroup();
            const double norm             = 0.01;

            var importer = new GrassCoverErosionInwardsCalculationConfigurationImporter(
                filePath,
                calculationGroup,
                new FailureMechanismContribution(norm, 0.001),
                Enumerable.Empty <HydraulicBoundaryLocation>(),
                Enumerable.Empty <DikeProfile>());

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

            // Assert
            Assert.IsTrue(successful);

            var expectedCalculation = new GrassCoverErosionInwardsCalculationScenario
            {
                Name            = "Berekening 1",
                InputParameters =
                {
                    DikeHeightTargetProbability      = norm,
                    OvertoppingRateTargetProbability = norm
                }
            };

            Assert.AreEqual(1, calculationGroup.Children.Count);
            AssertCalculationScenario(expectedCalculation, (GrassCoverErosionInwardsCalculationScenario)calculationGroup.Children[0]);
        }
Esempio n. 20
0
        public void IsDikeProfileIntersectionWithReferenceLineInSection_DikeProfileDoesNotIntersectReferenceLine_ReturnsFalse()
        {
            // Setup
            DikeProfile dikeProfile   = DikeProfileTestFactory.CreateDikeProfile(new Point2D(0.0, 0.0));
            var         referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(new[]
            {
                new Point2D(10.0, 0.0),
                new Point2D(20.0, 0.0)
            });

            var calculation = new GrassCoverErosionInwardsCalculationScenario
            {
                InputParameters =
                {
                    DikeProfile = dikeProfile
                }
            };

            IEnumerable <Segment2D> lineSegments = Math2D.ConvertPointsToLineSegments(referenceLine.Points);

            // Call
            bool intersects = calculation.IsDikeProfileIntersectionWithReferenceLineInSection(lineSegments);

            // Assert
            Assert.IsFalse(intersects);
        }
Esempio n. 21
0
        /// <summary>
        /// Creates a calculated scenario for which the surface line on the input intersects with <paramref name="section"/>.
        /// </summary>
        /// <param name="section">The section for which an intersection will be created.</param>
        /// <returns>A new <see cref="GrassCoverErosionInwardsCalculationScenario"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="section"/> is <c>null</c>.</exception>
        public static GrassCoverErosionInwardsCalculationScenario CreateGrassCoverErosionInwardsCalculationScenario(FailureMechanismSection section)
        {
            GrassCoverErosionInwardsCalculationScenario scenario = CreateNotCalculatedGrassCoverErosionInwardsCalculationScenario(section);

            scenario.Output = new TestGrassCoverErosionInwardsOutput();

            return(scenario);
        }
Esempio n. 22
0
        public void DikeHeight_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged()
        {
            // Setup
            var newValue = new RoundedDouble(2, 2.08);

            var calculation = new GrassCoverErosionInwardsCalculationScenario();

            // Call & Assert
            SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.DikeHeight = newValue, calculation);
        }
Esempio n. 23
0
        public void StandardDeviationCriticalFlowRate_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged()
        {
            // Setup
            var newValue = new RoundedDouble(4, 0.0004);

            var calculation = new GrassCoverErosionInwardsCalculationScenario();

            // Call & Assert
            SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.StandardDeviationCriticalFlowRate = newValue, calculation);
        }
Esempio n. 24
0
        public void UseForeShoreGeometry_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged()
        {
            // Setup
            const bool newValue = true;

            var calculation = new GrassCoverErosionInwardsCalculationScenario();

            // Call & Assert
            SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.UseForeshoreGeometry = newValue, calculation);
        }
Esempio n. 25
0
        public void DikeProfile_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged()
        {
            // Setup
            DikeProfile newProfile = DikeProfileTestFactory.CreateDikeProfile(new Point2D(0.0, 0.0));
            var         newValue   = new DataGridViewComboBoxItemWrapper <DikeProfile>(newProfile);

            var calculation = new GrassCoverErosionInwardsCalculationScenario();

            // Call & Assert
            SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.DikeProfile = newValue, calculation);
        }
Esempio n. 26
0
        public void Constructor_WithCalculationWithoutOutput_PropertiesFromCalculation()
        {
            // Setup
            var calculation = new GrassCoverErosionInwardsCalculationScenario();

            // Call
            var row = new GrassCoverErosionInwardsScenarioRow(calculation);

            // Assert
            Assert.IsNaN(row.FailureProbability);
        }
Esempio n. 27
0
        public void IsDikeProfileIntersectionWithReferenceLineInSection_CalculationWithoutDikeProfile_ReturnsFalse()
        {
            // Setup
            var calculation = new GrassCoverErosionInwardsCalculationScenario();

            // Call
            bool intersects = calculation.IsDikeProfileIntersectionWithReferenceLineInSection(Enumerable.Empty <Segment2D>());

            // Assert
            Assert.IsFalse(intersects);
        }
        public void Clone_NotAllPropertiesSet_ReturnsCopiedInstanceWithPropertiesSet()
        {
            // Setup
            GrassCoverErosionInwardsCalculationScenario original = CreateRandomCalculationScenarioWithoutOutput();

            // Call
            object clone = original.Clone();

            // Assert
            CoreCloneAssert.AreObjectClones(original, clone, GrassCoverErosionInwardsCloneAssert.AreClones);
        }
Esempio n. 29
0
        public void SelectableHydraulicBoundaryLocation_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged()
        {
            // Setup
            var newLocation = new TestHydraulicBoundaryLocation();
            var selectableHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation(newLocation, new Point2D(0, 0));
            var newValue = new DataGridViewComboBoxItemWrapper <SelectableHydraulicBoundaryLocation>(selectableHydraulicBoundaryLocation);

            var calculation = new GrassCoverErosionInwardsCalculationScenario();

            // Call & Assert
            SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.SelectableHydraulicBoundaryLocation = newValue, calculation);
        }
Esempio n. 30
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var calculation = new GrassCoverErosionInwardsCalculationScenario();

            // Call
            var row = new GrassCoverErosionInwardsScenarioRow(calculation);

            // Assert
            Assert.IsInstanceOf <ScenarioRow <GrassCoverErosionInwardsCalculationScenario> >(row);
            Assert.AreSame(calculation, row.CalculationScenario);
        }