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

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

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

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

            // Precondition
            CollectionAssert.IsNotEmpty(calculationsWithSurfaceLine);

            // Call
            IEnumerable <IObservable> observables = MacroStabilityInwardsDataSynchronizationService.RemoveAllSurfaceLines(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.SurfaceLines);
            foreach (MacroStabilityInwardsCalculation calculation in calculationsWithSurfaceLine)
            {
                Assert.IsNull(calculation.InputParameters.SurfaceLine);
            }

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

            Assert.AreEqual(expectedAffectedObjectCount, affectedObjectsArray.Length);

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

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

            CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjectsArray);
        }
Ejemplo n.º 3
0
 protected override IEnumerable <IObservable> ClearData()
 {
     return(MacroStabilityInwardsDataSynchronizationService.RemoveAllSurfaceLines(FailureMechanism));
 }