コード例 #1
0
        public void RemoveSurfaceLine_PipingFailureMechanismNull_ThrowsArgumentNullException()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            // Call
            void Call() => PipingDataSynchronizationService.RemoveSurfaceLine(null, surfaceLine);

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

            Assert.AreEqual("failureMechanism", exception.ParamName);
        }
コード例 #2
0
        public void RemoveSurfaceLine_SurfaceLineNull_ThrowsArgumentNullException()
        {
            // Setup
            var failureMechanism = new PipingFailureMechanism();

            // Call
            void Call() => PipingDataSynchronizationService.RemoveSurfaceLine(failureMechanism, null);

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

            Assert.AreEqual("surfaceLine", exception.ParamName);
        }
コード例 #3
0
        public void RemoveSurfaceLine_FullyConfiguredPipingFailureMechanism_RemoveSurfaceLineAndClearDependentData()
        {
            // Setup
            PipingFailureMechanism failureMechanism = PipingTestDataGenerator.GetPipingFailureMechanismWithAllCalculationConfigurations();
            PipingSurfaceLine      surfaceLine      = failureMechanism.SurfaceLines[0];

            IPipingCalculationScenario <PipingInput>[] calculationsWithSurfaceLine = failureMechanism.Calculations
                                                                                     .Cast <IPipingCalculationScenario <PipingInput> >()
                                                                                     .Where(c => ReferenceEquals(c.InputParameters.SurfaceLine, surfaceLine))
                                                                                     .ToArray();
            IPipingCalculationScenario <PipingInput>[] calculationsWithOutput = calculationsWithSurfaceLine.Where(c => c.HasOutput)
                                                                                .ToArray();

            // Precondition
            CollectionAssert.IsNotEmpty(calculationsWithSurfaceLine);

            // Call
            IEnumerable <IObservable> observables = PipingDataSynchronizationService.RemoveSurfaceLine(failureMechanism, surfaceLine);

            // 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.DoesNotContain(failureMechanism.SurfaceLines, surfaceLine);
            foreach (IPipingCalculationScenario <PipingInput> 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 (IPipingCalculationScenario <PipingInput> 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);
        }
コード例 #4
0
 protected override IEnumerable <IObservable> RemoveObjectAndDependentData(PipingSurfaceLine removedObject)
 {
     return(PipingDataSynchronizationService.RemoveSurfaceLine(FailureMechanism, removedObject));
 }