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

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

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

            MacroStabilityInwardsCalculation[] calculationsWithStochasticSoilModel = failureMechanism.Calculations
                                                                                     .Cast <MacroStabilityInwardsCalculation>()
                                                                                     .Where(calc => calc.InputParameters.StochasticSoilModel != null)
                                                                                     .ToArray();
            MacroStabilityInwardsCalculation[] calculationsWithOutput = calculationsWithStochasticSoilModel.Where(c => c.HasOutput)
                                                                        .ToArray();

            // Precondition
            CollectionAssert.IsNotEmpty(calculationsWithStochasticSoilModel);

            // Call
            IEnumerable <IObservable> observables = MacroStabilityInwardsDataSynchronizationService.RemoveAllStochasticSoilModels(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:
            CollectionAssert.IsEmpty(failureMechanism.StochasticSoilModels);
            foreach (MacroStabilityInwardsCalculation calculation in calculationsWithStochasticSoilModel)
            {
                Assert.IsNull(calculation.InputParameters.StochasticSoilModel);
            }

            IObservable[] affectedObjectsArray        = observables.ToArray();
            int           expectedAffectedObjectCount = 1 + calculationsWithOutput.Length + calculationsWithStochasticSoilModel.Length;

            Assert.AreEqual(expectedAffectedObjectCount, affectedObjectsArray.Length);

            foreach (MacroStabilityInwardsCalculation calculation in calculationsWithOutput)
            {
                Assert.IsFalse(calculation.HasOutput);
            }

            IEnumerable <IObservable> expectedAffectedObjects =
                calculationsWithStochasticSoilModel.Select(calc => calc.InputParameters)
                .Cast <IObservable>()
                .Concat(calculationsWithOutput)
                .Concat(new IObservable[]
            {
                failureMechanism.StochasticSoilModels
            });

            CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjectsArray);
        }
 protected override IEnumerable <IObservable> ClearData()
 {
     return(MacroStabilityInwardsDataSynchronizationService.RemoveAllStochasticSoilModels(FailureMechanism));
 }