Esempio n. 1
0
        /// <summary>
        /// Removes a given <see cref="PipingStochasticSoilModel"/> from the <see cref="PipingFailureMechanism"/>
        /// and clears all data that depends on it, either directly or indirectly.
        /// </summary>
        /// <param name="failureMechanism">The failure mechanism containing <paramref name="soilModel"/>.</param>
        /// <param name="soilModel">The soil model residing in <paramref name="failureMechanism"/>
        /// that should be removed.</param>
        /// <returns>All observable objects affected by this method.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="failureMechanism"/>
        /// or <paramref name="soilModel"/> is <c>null</c>.</exception>
        public static IEnumerable <IObservable> RemoveStochasticSoilModel(PipingFailureMechanism failureMechanism,
                                                                          PipingStochasticSoilModel soilModel)
        {
            if (failureMechanism == null)
            {
                throw new ArgumentNullException(nameof(failureMechanism));
            }

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

            var changedObservables = new List <IObservable>();

            IEnumerable <IPipingCalculationScenario <PipingInput> > pipingCalculations =
                failureMechanism.Calculations
                .Cast <IPipingCalculationScenario <PipingInput> >()
                .Where(pcs => ReferenceEquals(pcs.InputParameters.StochasticSoilModel, soilModel));

            foreach (IPipingCalculationScenario <PipingInput> pipingCalculation in pipingCalculations)
            {
                changedObservables.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(pipingCalculation));
                changedObservables.AddRange(ClearStochasticSoilModel(pipingCalculation.InputParameters));
            }

            failureMechanism.StochasticSoilModels.Remove(soilModel);
            changedObservables.Add(failureMechanism.StochasticSoilModels);

            return(changedObservables);
        }
Esempio n. 2
0
        protected override void PerformCalculation()
        {
            calculationService.OnProgressChanged += UpdateProgressText;

            RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculation);
            calculationService.Calculate(calculation, failureMechanism, assessmentSection);
        }
Esempio n. 3
0
        public void ClearHydraulicBoundaryLocationCalculationOutput_CalculationsWithAndWithoutOutput_ClearsOutputAndReturnsAffectedCalculations()
        {
            // Setup
            var random = new Random(21);

            var calculationWithOutput1 = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation())
            {
                Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble())
            };

            var calculationWithOutput2 = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation())
            {
                Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble())
            };

            HydraulicBoundaryLocationCalculation[] calculations =
            {
                new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()),
                calculationWithOutput1,
                new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()),
                calculationWithOutput2,
                new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation())
            };

            // Call
            IEnumerable <IObservable> affectedCalculations = RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationOutput(calculations);

            // Assert
            Assert.IsTrue(calculations.All(c => c.Output == null));
            CollectionAssert.AreEqual(new[]
            {
                calculationWithOutput1,
                calculationWithOutput2
            }, affectedCalculations);
        }
Esempio n. 4
0
        /// <summary>
        /// Removes a given <see cref="MacroStabilityInwardsStochasticSoilModel"/> from the <see cref="MacroStabilityInwardsFailureMechanism"/>
        /// and clears all data that depends on it, either directly or indirectly.
        /// </summary>
        /// <param name="failureMechanism">The failure mechanism containing <paramref name="soilModel"/>.</param>
        /// <param name="soilModel">The soil model residing in <paramref name="failureMechanism"/>
        /// that should be removed.</param>
        /// <returns>All observable objects affected by this method.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="failureMechanism"/>
        /// or <paramref name="soilModel"/> is <c>null</c>.</exception>
        public static IEnumerable <IObservable> RemoveStochasticSoilModel(MacroStabilityInwardsFailureMechanism failureMechanism, MacroStabilityInwardsStochasticSoilModel soilModel)
        {
            if (failureMechanism == null)
            {
                throw new ArgumentNullException(nameof(failureMechanism));
            }

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

            var changedObservables = new List <IObservable>();

            IEnumerable <MacroStabilityInwardsCalculation> calculationScenarios =
                failureMechanism.Calculations
                .Cast <MacroStabilityInwardsCalculation>()
                .Where(pcs => ReferenceEquals(pcs.InputParameters.StochasticSoilModel, soilModel));

            foreach (MacroStabilityInwardsCalculation calculationScenario in calculationScenarios)
            {
                changedObservables.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculationScenario));
                changedObservables.AddRange(ClearStochasticSoilModel(calculationScenario.InputParameters));
            }

            failureMechanism.StochasticSoilModels.Remove(soilModel);
            changedObservables.Add(failureMechanism.StochasticSoilModels);

            return(changedObservables);
        }
Esempio n. 5
0
        /// <summary>
        /// Clears the output for all calculations that corresponds with the <paramref name="calculationsForTargetProbability"/>
        /// in the given <paramref name="failureMechanism"/>.
        /// </summary>
        /// <param name="failureMechanism">The failure mechanism which contains the calculations.</param>
        /// <param name="calculationsForTargetProbability">The <see cref="HydraulicBoundaryLocationCalculationsForTargetProbability"/>
        /// to clear for.</param>
        /// <typeparam name="TFailureMechanism">The type of the calculatable failure mechanism.</typeparam>
        /// <typeparam name="TCalculation">The type of the calculation.</typeparam>
        /// <returns>An <see cref="IEnumerable{T}"/> of calculations which are affected by clearing the output.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static IEnumerable <IObservable> ClearAllWaveConditionsCalculationOutput <TFailureMechanism, TCalculation>(
            TFailureMechanism failureMechanism, HydraulicBoundaryLocationCalculationsForTargetProbability calculationsForTargetProbability)
            where TFailureMechanism : ICalculatableFailureMechanism
            where TCalculation : ICalculation <WaveConditionsInput>
        {
            if (failureMechanism == null)
            {
                throw new ArgumentNullException(nameof(failureMechanism));
            }

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

            var affectedItems = new List <IObservable>();

            foreach (TCalculation calculation in failureMechanism.Calculations
                     .Cast <TCalculation>()
                     .Where(c => c.InputParameters.WaterLevelType == WaveConditionsInputWaterLevelType.UserDefinedTargetProbability &&
                            c.InputParameters.CalculationsTargetProbability == calculationsForTargetProbability))
            {
                affectedItems.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculation));
            }

            return(affectedItems);
        }
        protected override void PerformCalculation()
        {
            RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculation);

            calculationService.Calculate(
                calculation,
                assessmentSection,
                failureMechanism.GeneralInput);
        }
Esempio n. 7
0
        public void ClearHydraulicBoundaryLocationCalculationOutput_CalculationsNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationOutput(null);

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

            Assert.AreEqual("calculations", exception.ParamName);
        }
Esempio n. 8
0
        public void ClearStructuresCalculationIllustrationPoints_CalculationsNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => RiskeerCommonDataSynchronizationService.ClearStructuresCalculationIllustrationPoints(null);

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

            Assert.AreEqual("calculations", exception.ParamName);
        }
Esempio n. 9
0
        public void ClearForeshoreProfile_CalculationsWithForeshoreProfile_ClearForeshoreProfileAndReturnAffectedInputs()
        {
            // Setup
            var foreshoreProfileToBeRemoved = new TestForeshoreProfile(new Point2D(0, 0));
            var foreshoreProfile            = new TestForeshoreProfile(new Point2D(1, 1));

            var calculation1 = new StructuresCalculation <TestStructuresInput>
            {
                InputParameters =
                {
                    ForeshoreProfile = foreshoreProfile
                }
            };
            var calculation2 = new StructuresCalculation <TestStructuresInput>
            {
                InputParameters =
                {
                    ForeshoreProfile = foreshoreProfileToBeRemoved
                }
            };
            var calculation3 = new StructuresCalculation <TestStructuresInput>
            {
                InputParameters =
                {
                    ForeshoreProfile = foreshoreProfileToBeRemoved
                },
                Output = new TestStructuresOutput()
            };

            StructuresCalculation <TestStructuresInput>[] calculations =
            {
                calculation1,
                calculation2,
                calculation3
            };

            // Call
            IEnumerable <IObservable> affectedObjects = RiskeerCommonDataSynchronizationService.ClearForeshoreProfile <TestStructuresInput, TestStructure>(
                calculations, foreshoreProfileToBeRemoved);

            // Assert
            Assert.IsNull(calculation2.InputParameters.ForeshoreProfile);
            Assert.IsNull(calculation3.InputParameters.ForeshoreProfile);
            Assert.IsFalse(calculation3.HasOutput);
            Assert.IsNotNull(calculation1.InputParameters.ForeshoreProfile);

            CollectionAssert.AreEqual(new IObservable[]
            {
                calculation2.InputParameters,
                calculation3,
                calculation3.InputParameters
            }, affectedObjects);
        }
Esempio n. 10
0
        private static IEnumerable <IObservable> RemoveSurfaceLineDependentData(IEnumerable <MacroStabilityInwardsCalculation> calculationScenarios)
        {
            var changedObservables = new List <IObservable>();

            foreach (MacroStabilityInwardsCalculation calculationScenario in calculationScenarios)
            {
                changedObservables.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculationScenario));
                changedObservables.AddRange(ClearSurfaceLine(calculationScenario.InputParameters));
            }

            return(changedObservables);
        }
Esempio n. 11
0
        private static IEnumerable <IObservable> RemoveSurfaceLineDependentData(IEnumerable <IPipingCalculationScenario <PipingInput> > pipingCalculations)
        {
            var changedObservables = new List <IObservable>();

            foreach (IPipingCalculationScenario <PipingInput> pipingCalculation in pipingCalculations)
            {
                changedObservables.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(pipingCalculation));
                changedObservables.AddRange(ClearSurfaceLine(pipingCalculation.InputParameters));
            }

            return(changedObservables);
        }
        private static IEnumerable <IObservable> ClearDikeProfileDependentData(
            IEnumerable <GrassCoverErosionInwardsCalculation> calculationsWithRemovedDikeProfile)
        {
            var affectedObjects = new List <IObservable>();

            foreach (GrassCoverErosionInwardsCalculation calculation in calculationsWithRemovedDikeProfile)
            {
                affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculation));
                affectedObjects.AddRange(ClearDikeProfile(calculation.InputParameters));
            }

            return(affectedObjects);
        }
        private IEnumerable <IObservable> UpdateSurfaceLineDependentData(PipingSurfaceLine surfaceLine)
        {
            IEnumerable <IPipingCalculationScenario <PipingInput> > affectedCalculations = GetAffectedCalculationWithSurfaceLine(surfaceLine);

            var affectedObjects = new List <IObservable>();

            foreach (IPipingCalculationScenario <PipingInput> affectedCalculation in affectedCalculations)
            {
                affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(affectedCalculation));
            }

            return(affectedObjects);
        }
Esempio n. 14
0
        private IEnumerable <IObservable> UpdateSurfaceLineDependentData(MacroStabilityInwardsSurfaceLine surfaceLine)
        {
            IEnumerable <MacroStabilityInwardsCalculation> affectedCalculations = GetAffectedCalculationWithSurfaceLine(surfaceLine);

            var affectedObjects = new List <IObservable>();

            foreach (MacroStabilityInwardsCalculation affectedCalculation in affectedCalculations)
            {
                affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(affectedCalculation));
            }

            return(affectedObjects);
        }
        private static List <IObservable> ClearStructureDependentData(IEnumerable <StructuresCalculation <StabilityPointStructuresInput> > calculationWithRemovedStructure)
        {
            var changedObservables = new List <IObservable>();

            foreach (StructuresCalculation <StabilityPointStructuresInput> calculation in calculationWithRemovedStructure)
            {
                changedObservables.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculation));

                calculation.InputParameters.ClearStructure();
                changedObservables.Add(calculation.InputParameters);
            }

            return(changedObservables);
        }
        protected override IEnumerable <IObservable> RemoveObjectAndDependentData(ForeshoreProfile removedObject)
        {
            IEnumerable <ICalculation <ICalculationInput> > affectedCalculations = GetAffectedCalculationWithForeshoreProfiles(removedObject);

            var affectedObjects = new List <IObservable>();

            foreach (ICalculation <ICalculationInput> calculation in affectedCalculations)
            {
                ((IHasForeshoreProfile)calculation.InputParameters).ForeshoreProfile = null;
                affectedObjects.Add(calculation.InputParameters);
                affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculation));
            }

            return(affectedObjects);
        }
Esempio n. 17
0
        public void ClearHydraulicBoundaryLocation_InputWithoutHydraulicBoundaryLocation_ReturnsNoAffectedObjects()
        {
            // Setup
            var mocks = new MockRepository();
            var input = mocks.Stub <ICalculationInputWithHydraulicBoundaryLocation>();

            mocks.ReplayAll();

            // Call
            IEnumerable <IObservable> affectedObjects = RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocation(input);

            // Assert
            CollectionAssert.IsEmpty(affectedObjects);
            mocks.VerifyAll();
        }
Esempio n. 18
0
        private static void UpdateStructureDerivedCalculationInput(StructuresCalculation <ClosingStructuresInput> calculation)
        {
            calculation.InputParameters.SynchronizeStructureInput();

            var affectedObjects = new List <IObservable>
            {
                calculation.InputParameters
            };

            affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculation));

            foreach (IObservable affectedObject in affectedObjects)
            {
                affectedObject.NotifyObservers();
            }
        }
Esempio n. 19
0
        private IEnumerable <IObservable> ClearNormDependingHydraulicBoundaryLocationCalculationOutput(bool normativeProbability)
        {
            NormativeProbabilityType normativeProbabilityToClearFor = GetNormativeProbabilityToClearFor(normativeProbability, assessmentSection.FailureMechanismContribution.NormativeProbabilityType);
            IEnumerable <HydraulicBoundaryLocationCalculation> calculationsToClear = GetHydraulicBoundaryLocationCalculationsToClear(normativeProbabilityToClearFor);

            var affectedObjects = new List <IObservable>();

            affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationOutput(calculationsToClear));
            affectedObjects.AddRange(RiskeerDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(assessmentSection, normativeProbabilityToClearFor));

            if (affectedObjects.Any())
            {
                log.Info(Resources.FailureMechanismContributionNormChangeHandler_ClearNormDependingHydraulicBoundaryLocationCalculationOutput_Calculation_results_cleared);
            }

            return(affectedObjects);
        }
Esempio n. 20
0
        public void ClearCalculationOutput_CalculationWithoutOutput_DoNothing()
        {
            // Setup
            var mocks       = new MockRepository();
            var calculation = mocks.StrictMock <ICalculation>();

            calculation.Expect(c => c.HasOutput).Return(false);
            mocks.ReplayAll();

            // Call
            IEnumerable <IObservable> changedObjects = RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculation);

            // Assert
            CollectionAssert.IsEmpty(changedObjects);

            mocks.VerifyAll();
        }
Esempio n. 21
0
        /// <summary>
        /// Clears:
        /// <list type="bullet">
        /// <item>The <see cref="HydraulicBoundaryLocation"/> for all the calculations in the <see cref="MacroStabilityInwardsFailureMechanism"/>;</item>
        /// <item>The output for all the calculations in the <see cref="MacroStabilityInwardsFailureMechanism"/>,
        /// except where <see cref="MacroStabilityInwardsInput.UseAssessmentLevelManualInput"/> is <c>true</c>.</item>
        /// </list>
        /// </summary>
        /// <param name="failureMechanism">The <see cref="MacroStabilityInwardsFailureMechanism"/> which contains the calculations.</param>
        /// <returns>An <see cref="IEnumerable{T}"/> of objects which are affected by removing data.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="failureMechanism"/> is <c>null</c>.</exception>
        public static IEnumerable <IObservable> ClearAllCalculationOutputAndHydraulicBoundaryLocations(MacroStabilityInwardsFailureMechanism failureMechanism)
        {
            if (failureMechanism == null)
            {
                throw new ArgumentNullException(nameof(failureMechanism));
            }

            var affectedItems = new List <IObservable>();

            foreach (MacroStabilityInwardsCalculation calculation in failureMechanism.Calculations.Cast <MacroStabilityInwardsCalculation>())
            {
                affectedItems.AddRange(ClearAllCalculationOutputWithoutManualAssessmentLevel(failureMechanism));
                affectedItems.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocation(calculation.InputParameters));
            }

            return(affectedItems);
        }
Esempio n. 22
0
        private IEnumerable <IObservable> UpdateDikeDependentData(DikeProfile objectToUpdate)
        {
            var affectedObjects = new List <IObservable>();

            foreach (GrassCoverErosionInwardsCalculation calculation in GetAffectedCalculationsWithDikeProfile(objectToUpdate))
            {
                affectedObjects.Add(calculation.InputParameters);
                affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculation));

                if (!objectToUpdate.ForeshoreGeometry.Any())
                {
                    calculation.InputParameters.UseForeshore = false;
                }
            }

            return(affectedObjects);
        }
Esempio n. 23
0
        /// <summary>
        /// Clears the <see cref="HydraulicBoundaryLocation"/> and output for all the calculations
        /// in the <see cref="StructuresCalculation{T}"/>.
        /// </summary>
        /// <param name="failureMechanism">The <see cref="ClosingStructuresFailureMechanism"/>
        /// which contains the calculations.</param>
        /// <returns>An <see cref="IEnumerable{T}"/> of objects which are affected by removing data.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="failureMechanism"/>
        /// is <c>null</c>.</exception>
        public static IEnumerable <IObservable> ClearAllCalculationOutputAndHydraulicBoundaryLocations(ClosingStructuresFailureMechanism failureMechanism)
        {
            if (failureMechanism == null)
            {
                throw new ArgumentNullException(nameof(failureMechanism));
            }

            var affectedItems = new List <IObservable>();

            foreach (StructuresCalculation <ClosingStructuresInput> calculation in failureMechanism.Calculations.Cast <StructuresCalculation <ClosingStructuresInput> >())
            {
                affectedItems.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculation));
                affectedItems.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocation(calculation.InputParameters));
            }

            return(affectedItems);
        }
        /// <summary>
        /// Clears the <see cref="HydraulicBoundaryLocation"/> and output for all the wave conditions calculations
        /// in the <see cref="WaveImpactAsphaltCoverFailureMechanism"/>.
        /// </summary>
        /// <param name="failureMechanism">The <see cref="WaveImpactAsphaltCoverFailureMechanism"/>
        /// which contains the calculations.</param>
        /// <returns>An <see cref="IEnumerable{T}"/> of objects which are affected by removing data.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="failureMechanism"/>
        /// is <c>null</c>.</exception>
        public static IEnumerable <IObservable> ClearAllWaveConditionsCalculationOutputAndHydraulicBoundaryLocations(
            WaveImpactAsphaltCoverFailureMechanism failureMechanism)
        {
            if (failureMechanism == null)
            {
                throw new ArgumentNullException(nameof(failureMechanism));
            }

            var affectedItems = new List <IObservable>();

            foreach (WaveImpactAsphaltCoverWaveConditionsCalculation calculation in failureMechanism.Calculations.Cast <WaveImpactAsphaltCoverWaveConditionsCalculation>())
            {
                affectedItems.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculation));
                affectedItems.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocation(calculation.InputParameters));
            }

            return(affectedItems);
        }
Esempio n. 25
0
        /// <summary>
        /// Clears:
        /// <list type="bullet">
        /// <item>The <see cref="HydraulicBoundaryLocation"/> for all the calculations in the <see cref="PipingFailureMechanism"/>;</item>
        /// <item>The output for all the calculations in the <see cref="PipingFailureMechanism"/>,
        /// except for the <see cref="SemiProbabilisticPipingCalculationScenario"/> where
        /// <see cref="SemiProbabilisticPipingInput.UseAssessmentLevelManualInput"/> is <c>true</c>.</item>
        /// </list>
        /// </summary>
        /// <param name="failureMechanism">The <see cref="PipingFailureMechanism"/> which contains the calculations.</param>
        /// <returns>An <see cref="IEnumerable{T}"/> of objects which are affected by removing data.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="failureMechanism"/> is <c>null</c>.</exception>
        public static IEnumerable <IObservable> ClearAllCalculationOutputAndHydraulicBoundaryLocations(PipingFailureMechanism failureMechanism)
        {
            if (failureMechanism == null)
            {
                throw new ArgumentNullException(nameof(failureMechanism));
            }

            var affectedItems = new List <IObservable>();

            affectedItems.AddRange(ClearAllSemiProbabilisticCalculationOutputWithoutManualAssessmentLevel(failureMechanism));
            affectedItems.AddRange(ClearAllProbabilisticCalculationOutput(failureMechanism));

            foreach (IPipingCalculationScenario <PipingInput> calculation in failureMechanism.Calculations.Cast <IPipingCalculationScenario <PipingInput> >())
            {
                affectedItems.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocation(calculation.InputParameters));
            }

            return(affectedItems.Distinct());
        }
Esempio n. 26
0
        public void ClearHydraulicBoundaryLocation_InputWithHydraulicBoundaryLocation_ClearsLocationAndReturnsAffectedInput()
        {
            // Setup
            var mocks = new MockRepository();
            var input = mocks.Stub <ICalculationInputWithHydraulicBoundaryLocation>();

            mocks.ReplayAll();

            input.HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();

            // Call
            IEnumerable <IObservable> affectedObjects = RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocation(input);

            // Assert
            Assert.IsNull(input.HydraulicBoundaryLocation);
            CollectionAssert.AreEqual(new[]
            {
                input
            }, affectedObjects);
            mocks.VerifyAll();
        }
        protected override IEnumerable <IObservable> UpdateObjectAndDependentData(ForeshoreProfile objectToUpdate, ForeshoreProfile objectToUpdateFrom)
        {
            objectToUpdate.CopyProperties(objectToUpdateFrom);

            var affectedObjects = new List <IObservable>();

            IEnumerable <ICalculation <ICalculationInput> > affectedCalculations = GetAffectedCalculationWithForeshoreProfiles(objectToUpdate);

            foreach (ICalculation <ICalculationInput> calculation in affectedCalculations)
            {
                affectedObjects.Add(calculation.InputParameters);
                affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculation));

                if (!objectToUpdate.Geometry.Any())
                {
                    ((IUseForeshore)calculation.InputParameters).UseForeshore = false;
                }
            }

            return(affectedObjects);
        }
Esempio n. 28
0
        /// <summary>
        /// Clears data dependent on a given <see cref="MacroStabilityInwardsStochasticSoilProfile"/>, either directly or indirectly,
        /// from calculations in the <see cref="MacroStabilityInwardsFailureMechanism"/>.
        /// </summary>
        /// <param name="failureMechanism">The failure mechanism containing <paramref name="soilProfile"/>.</param>
        /// <param name="soilProfile">The soil profile residing in <paramref name="failureMechanism"/>
        /// that has been updated.</param>
        /// <returns>All observable objects affected by this method.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="failureMechanism"/>
        /// or <paramref name="soilProfile"/> is <c>null</c>.</exception>
        public static IEnumerable <IObservable> ClearStochasticSoilProfileDependentData(MacroStabilityInwardsFailureMechanism failureMechanism, MacroStabilityInwardsStochasticSoilProfile soilProfile)
        {
            if (failureMechanism == null)
            {
                throw new ArgumentNullException(nameof(failureMechanism));
            }

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

            var changedObservables = new List <IObservable>();

            foreach (MacroStabilityInwardsCalculation calculation in GetCalculationsWithSoilProfileAssigned(failureMechanism, soilProfile))
            {
                changedObservables.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculation));
                changedObservables.Add(calculation.InputParameters);
            }

            return(changedObservables);
        }
Esempio n. 29
0
        public void ClearCalculationOutput_WithCalculation_ClearsOutput()
        {
            // Setup
            var mocks       = new MockRepository();
            var calculation = mocks.StrictMock <ICalculation>();

            calculation.Expect(c => c.HasOutput).Return(true);
            calculation.Expect(c => c.ClearOutput());
            mocks.ReplayAll();

            // Call
            IEnumerable <IObservable> changedObjects = RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculation);

            // Assert
            // Note: To make sure the clear is performed regardless of what is done with
            // the return result, no ToArray() should be called before these assertions:
            mocks.VerifyAll();

            CollectionAssert.AreEqual(new[]
            {
                calculation
            }, changedObjects);
        }
Esempio n. 30
0
        /// <summary>
        /// Removes a given <see cref="PipingStochasticSoilProfile"/> from calculations in the <see cref="PipingFailureMechanism"/>
        /// and clears all data that depends on it, either directly or indirectly.
        /// </summary>
        /// <param name="failureMechanism">The failure mechanism containing <paramref name="soilProfile"/>.</param>
        /// <param name="soilProfile">The soil profile residing in <paramref name="failureMechanism"/>
        /// that has been removed.</param>
        /// <returns>All observable objects affected by this method.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="failureMechanism"/>
        /// or <paramref name="soilProfile"/> is <c>null</c>.</exception>
        public static IEnumerable <IObservable> RemoveStochasticSoilProfileFromInput(PipingFailureMechanism failureMechanism,
                                                                                     PipingStochasticSoilProfile soilProfile)
        {
            if (failureMechanism == null)
            {
                throw new ArgumentNullException(nameof(failureMechanism));
            }

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

            var changedObservables = new List <IObservable>();

            foreach (IPipingCalculationScenario <PipingInput> pipingCalculation in GetCalculationsWithSoilProfileAssigned(failureMechanism, soilProfile))
            {
                changedObservables.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(pipingCalculation));
                changedObservables.AddRange(ClearStochasticSoilProfile(pipingCalculation.InputParameters));
            }

            return(changedObservables);
        }