示例#1
0
        public void ClearStructuresCalculationIllustrationPoints_CalculationsNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => RiskeerCommonDataSynchronizationService.ClearStructuresCalculationIllustrationPoints(null);

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

            Assert.AreEqual("calculations", exception.ParamName);
        }
示例#2
0
        public void ClearStructuresCalculationIllustrationPoints_CalculationsWithAndWithoutIllustrationPoints_ClearsIllustrationPointAndReturnsAffectedCalculations()
        {
            // Setup
            var originalOutputWithIllustrationPoints1 = new TestStructuresOutput(new TestGeneralResultFaultTreeIllustrationPoint());
            var calculationWithIllustrationPoints1    = new TestStructuresCalculation
            {
                Output = originalOutputWithIllustrationPoints1
            };

            var originalOutputWithIllustrationPoints2 = new TestStructuresOutput(new TestGeneralResultFaultTreeIllustrationPoint());
            var calculationWithIllustrationPoints2    = new TestStructuresCalculation
            {
                Output = originalOutputWithIllustrationPoints2
            };

            var originalOutput1        = new TestStructuresOutput();
            var calculationWithOutput1 = new TestStructuresCalculation
            {
                Output = originalOutput1
            };

            var originalOutput2        = new TestStructuresOutput();
            var calculationWithOutput2 = new TestStructuresCalculation
            {
                Output = originalOutput2
            };

            TestStructuresCalculation[] calculations =
            {
                new TestStructuresCalculation(),
                calculationWithOutput1,
                calculationWithIllustrationPoints1,
                new TestStructuresCalculation(),
                calculationWithOutput2,
                calculationWithIllustrationPoints2,
                new TestStructuresCalculation()
            };

            // Call
            IEnumerable <IObservable> affectedObjects = RiskeerCommonDataSynchronizationService.ClearStructuresCalculationIllustrationPoints(calculations);

            // Assert
            CollectionAssert.AreEquivalent(new[]
            {
                calculationWithIllustrationPoints1,
                calculationWithIllustrationPoints2
            }, affectedObjects);

            TestStructuresCalculation[] calculationsWithOutput =
            {
                calculationWithOutput1,
                calculationWithIllustrationPoints1,
                calculationWithOutput2,
                calculationWithIllustrationPoints2
            };

            Assert.IsTrue(calculationsWithOutput.All(calc => calc.HasOutput));
            Assert.IsTrue(calculationsWithOutput.All(calc => !calc.Output.HasGeneralResult));

            AssertStructuresOutput(originalOutput1, calculationWithOutput1.Output);
            AssertStructuresOutput(originalOutput2, calculationWithOutput2.Output);

            AssertStructuresOutput(originalOutputWithIllustrationPoints1, calculationWithIllustrationPoints1.Output);
            AssertStructuresOutput(originalOutputWithIllustrationPoints2, calculationWithIllustrationPoints2.Output);
        }
 public override IEnumerable <IObservable> ClearIllustrationPoints()
 {
     return(RiskeerCommonDataSynchronizationService.ClearStructuresCalculationIllustrationPoints(calculations));
 }