Ejemplo n.º 1
0
        public void ClearAllCalculationOutputAndHydraulicBoundaryLocations_FailureMechanismNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => MacroStabilityInwardsDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations(null);

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

            Assert.AreEqual("failureMechanism", exception.ParamName);
        }
Ejemplo n.º 2
0
        public void ClearAllCalculationOutputAndHydraulicBoundaryLocations_WithVariousCalculations_ClearsHydraulicBoundaryLocationAndCalculationsAndReturnsAffectedObjects()
        {
            // Setup
            MacroStabilityInwardsFailureMechanism failureMechanism = MacroStabilityInwardsTestDataGenerator.GetMacroStabilityInwardsFailureMechanismWithAllCalculationConfigurations();

            failureMechanism.CalculationsGroup.Children.Add(new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    UseAssessmentLevelManualInput = true
                },
                Output = MacroStabilityInwardsOutputTestFactory.CreateOutput()
            });

            MacroStabilityInwardsCalculation[] calculations = failureMechanism.Calculations
                                                              .Cast <MacroStabilityInwardsCalculation>()
                                                              .ToArray();

            var expectedAffectedItems = new List <IObservable>();

            expectedAffectedItems.AddRange(calculations.Where(c => !c.InputParameters.UseAssessmentLevelManualInput &&
                                                              c.HasOutput));
            expectedAffectedItems.AddRange(calculations.Select(c => c.InputParameters)
                                           .Where(i => i.HydraulicBoundaryLocation != null));

            // Call
            IEnumerable <IObservable> affectedItems = MacroStabilityInwardsDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations(failureMechanism);

            // 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:
            Assert.IsTrue(calculations.Where(c => !c.InputParameters.UseAssessmentLevelManualInput)
                          .All(c => c.InputParameters.HydraulicBoundaryLocation == null &&
                               !c.HasOutput));

            CollectionAssert.AreEquivalent(expectedAffectedItems, affectedItems);
        }