public void RemoveAllStochasticSoilModel_FullyConfiguredPipingFailureMechanism_RemovesAllSoilModelAndClearDependentData()
        {
            // Setup
            PipingFailureMechanism failureMechanism = PipingTestDataGenerator.GetPipingFailureMechanismWithAllCalculationConfigurations();

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

            // Precondition
            CollectionAssert.IsNotEmpty(calculationsWithStochasticSoilModel);

            // Call
            IEnumerable <IObservable> observables = PipingDataSynchronizationService.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 (IPipingCalculationScenario <PipingInput> 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 (IPipingCalculationScenario <PipingInput> 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);
        }
        public void ForeColor_HasOutput_ReturnControlText()
        {
            // Setup
            var calculation = new ProbabilisticPipingCalculationScenario
            {
                Output = PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithIllustrationPoints()
            };

            var context = new ProbabilisticPipingOutputContext(calculation);

            // Call
            Color color = info.ForeColor(context);

            // Assert
            Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color);
        }
        public void AdditionalDataCheck_CalculationWithoutSubMechanismOutput_ReturnsFalse()
        {
            // Setup
            var calculation = new ProbabilisticPipingCalculationScenario
            {
                Output = PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithIllustrationPoints()
            };

            var context = new ProbabilisticPipingSectionSpecificOutputContext(calculation);

            // Call
            bool additionalDataCheck = info.AdditionalDataCheck(context);

            // Assert
            Assert.IsFalse(additionalDataCheck);
        }
Exemplo n.º 4
0
        public void GivenScenarioRow_WhenOutputChangedAndUpdate_ThenDerivedOutputUpdated()
        {
            // Given
            var failureMechanism = new PipingFailureMechanism();

            var mocks = new MockRepository();
            IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);

            mocks.ReplayAll();

            var calculation = new SemiProbabilisticPipingCalculationScenario
            {
                Output = PipingTestDataGenerator.GetRandomSemiProbabilisticPipingOutput()
            };
            FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();

            var row = new SemiProbabilisticPipingScenarioRow(calculation, failureMechanism, failureMechanismSection, assessmentSection);

            // Precondition
            DerivedSemiProbabilisticPipingOutput expectedDerivedOutput = DerivedSemiProbabilisticPipingOutputFactory.Create(calculation.Output, assessmentSection.FailureMechanismContribution.NormativeProbability);

            Assert.AreEqual(expectedDerivedOutput.PipingProbability, row.FailureProbability);
            Assert.AreEqual(expectedDerivedOutput.UpliftProbability, row.FailureProbabilityUplift);
            Assert.AreEqual(expectedDerivedOutput.HeaveProbability, row.FailureProbabilityHeave);
            Assert.AreEqual(expectedDerivedOutput.SellmeijerProbability, row.FailureProbabilitySellmeijer);
            Assert.AreEqual(expectedDerivedOutput.PipingProbability * failureMechanism.PipingProbabilityAssessmentInput.GetN(
                                failureMechanismSection.Length),
                            row.SectionFailureProbability);

            var random = new Random(11);

            // When
            calculation.Output = PipingTestDataGenerator.GetSemiProbabilisticPipingOutput(random.NextDouble(), random.NextDouble(), random.NextDouble());
            row.Update();

            // Then
            DerivedSemiProbabilisticPipingOutput newExpectedDerivedOutput = DerivedSemiProbabilisticPipingOutputFactory.Create(calculation.Output, assessmentSection.FailureMechanismContribution.NormativeProbability);

            Assert.AreEqual(newExpectedDerivedOutput.PipingProbability, row.FailureProbability);
            Assert.AreEqual(newExpectedDerivedOutput.UpliftProbability, row.FailureProbabilityUplift);
            Assert.AreEqual(newExpectedDerivedOutput.HeaveProbability, row.FailureProbabilityHeave);
            Assert.AreEqual(newExpectedDerivedOutput.SellmeijerProbability, row.FailureProbabilitySellmeijer);
            Assert.AreEqual(newExpectedDerivedOutput.PipingProbability * failureMechanism.PipingProbabilityAssessmentInput.GetN(
                                failureMechanismSection.Length),
                            row.SectionFailureProbability);
            mocks.VerifyAll();
        }
Exemplo n.º 5
0
        public void GivenScenarioRow_WhenOutputSetAndUpdate_ThenDerivedOutputUpdated()
        {
            // Given
            var calculation = new ProbabilisticPipingCalculationScenario();
            var row         = new ProbabilisticPipingScenarioRow(calculation);

            // Precondition
            Assert.IsNaN(row.FailureProbability);
            Assert.IsNaN(row.SectionFailureProbability);

            // When
            calculation.Output = PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithoutIllustrationPoints();

            // Then
            Assert.AreEqual(StatisticsConverter.ReliabilityToProbability(calculation.Output.ProfileSpecificOutput.Reliability), row.FailureProbability);
            Assert.AreEqual(StatisticsConverter.ReliabilityToProbability(calculation.Output.SectionSpecificOutput.Reliability), row.SectionFailureProbability);
        }
        public void Create_CalculationWithOutput_ReturnEntityWithOutput()
        {
            // Setup
            var output = new ProbabilisticPipingOutput(PipingTestDataGenerator.GetRandomPartialProbabilisticFaultTreePipingOutput(null),
                                                       PipingTestDataGenerator.GetRandomPartialProbabilisticFaultTreePipingOutput(null));

            // Call
            ProbabilisticPipingCalculationOutputEntity entity = output.Create();

            // Assert
            Assert.AreEqual(output.ProfileSpecificOutput.Reliability, entity.ProfileSpecificReliability);
            Assert.AreEqual(output.SectionSpecificOutput.Reliability, entity.SectionSpecificReliability);
            Assert.IsNull(entity.GeneralResultFaultTreeIllustrationPointEntity);
            Assert.IsNull(entity.GeneralResultFaultTreeIllustrationPointEntity1);
            Assert.IsNull(entity.GeneralResultSubMechanismIllustrationPointEntity);
            Assert.IsNull(entity.GeneralResultSubMechanismIllustrationPointEntity1);
        }
Exemplo n.º 7
0
        public void Constructor_FailureMechanismNull_ThrowsArgumentNullException()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            // Call
            void Call() => new SemiProbabilisticPipingOutputContext(PipingTestDataGenerator.GetRandomSemiProbabilisticPipingOutput(), null, assessmentSection);

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

            Assert.AreEqual("failureMechanism", exception.ParamName);
            mocks.VerifyAll();
        }
        public void CreateInstance_WithContextWithOtherPartialOutput_Null()
        {
            // Setup
            var calculation = new ProbabilisticPipingCalculationScenario
            {
                Output = new ProbabilisticPipingOutput(PipingTestDataGenerator.GetRandomPartialProbabilisticPipingOutput(),
                                                       PipingTestDataGenerator.GetRandomPartialProbabilisticPipingOutput())
            };

            var context = new ProbabilisticPipingSectionSpecificOutputContext(calculation);

            // Call
            IObjectProperties objectProperties = info.CreateInstance(context);

            // Assert
            Assert.IsNull(objectProperties);
        }
Exemplo n.º 9
0
        private static IEnumerable <TestCaseData> GetCalculationConfigurations()
        {
            var calculationWithIllustrationPoints = new ProbabilisticPipingCalculationScenario
            {
                Output = PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithIllustrationPoints()
            };

            var calculationWithNoIllustrationPoints = new ProbabilisticPipingCalculationScenario
            {
                Output = PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithoutIllustrationPoints()
            };

            yield return(new TestCaseData(calculationWithIllustrationPoints, true));

            yield return(new TestCaseData(calculationWithNoIllustrationPoints, false));

            yield return(new TestCaseData(new ProbabilisticPipingCalculationScenario(), false));
        }
        public void AdditionalDataCheck_CalculationWithSubMechanismOutput_ReturnsTrue()
        {
            // Setup
            var calculation = new ProbabilisticPipingCalculationScenario
            {
                Output = new ProbabilisticPipingOutput(
                    PipingTestDataGenerator.GetRandomPartialProbabilisticSubMechanismPipingOutput(),
                    PipingTestDataGenerator.GetRandomPartialProbabilisticSubMechanismPipingOutput())
            };

            var context = new ProbabilisticPipingSectionSpecificOutputContext(calculation);

            // Call
            bool additionalDataCheck = info.AdditionalDataCheck(context);

            // Assert
            Assert.IsTrue(additionalDataCheck);
        }
        public void CreateInstance_WithContextWithPartialSubMechanismOutput_ExpectedProperties()
        {
            // Setup
            var calculation = new ProbabilisticPipingCalculationScenario
            {
                Output = new ProbabilisticPipingOutput(PipingTestDataGenerator.GetRandomPartialProbabilisticSubMechanismPipingOutput(),
                                                       PipingTestDataGenerator.GetRandomPartialProbabilisticSubMechanismPipingOutput())
            };

            var context = new ProbabilisticPipingSectionSpecificOutputContext(calculation);

            // Call
            IObjectProperties objectProperties = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <ProbabilisticSubMechanismPipingOutputProperties>(objectProperties);
            Assert.AreSame(context.WrappedData.Output.SectionSpecificOutput, objectProperties.Data);
        }
Exemplo n.º 12
0
        public void Clone_NotAllPropertiesSet_ReturnNewInstanceWithCopiedValues()
        {
            // Setup
            var original = new TestPipingInput();

            PipingTestDataGenerator.SetRandomDataToPipingInput(original);

            original.SurfaceLine               = null;
            original.StochasticSoilModel       = null;
            original.StochasticSoilProfile     = null;
            original.HydraulicBoundaryLocation = null;

            // Call
            object clone = original.Clone();

            // Assert
            CoreCloneAssert.AreObjectClones(original, clone, PipingCloneAssert.AreClones);
        }
        private static ProbabilisticPipingCalculationScenario CreateRandomCalculationScenarioWithoutOutput()
        {
            var random = new Random(21);

            var calculation = new ProbabilisticPipingCalculationScenario
            {
                Comments =
                {
                    Body = "Random body"
                },
                Name         = "Random name",
                IsRelevant   = random.NextBoolean(),
                Contribution = random.NextRoundedDouble()
            };

            PipingTestDataGenerator.SetRandomDataToPipingInput(calculation.InputParameters);

            return(calculation);
        }
        public void GetProperties_WithData_ReturnExpectedValues()
        {
            // Setup
            PartialProbabilisticSubMechanismPipingOutput output = PipingTestDataGenerator.GetRandomPartialProbabilisticSubMechanismPipingOutput();

            // Call
            var properties = new ProbabilisticSubMechanismPipingOutputProperties(output);

            // Assert
            Assert.AreEqual(ProbabilityFormattingHelper.Format(StatisticsConverter.ReliabilityToProbability(output.Reliability)), properties.Probability);
            Assert.AreEqual(output.Reliability, properties.Reliability, properties.Reliability.GetAccuracy());

            GeneralResult <TopLevelSubMechanismIllustrationPoint> generalResult = output.GeneralResult;

            CollectionAssert.AreEqual(generalResult.Stochasts, properties.AlphaValues);
            CollectionAssert.AreEqual(generalResult.Stochasts, properties.Durations);
            CollectionAssert.AreEqual(generalResult.TopLevelIllustrationPoints, properties.IllustrationPoints.Select(ip => ip.Data));
            Assert.AreEqual(generalResult.GoverningWindDirection.Name, properties.WindDirection);
        }
        public void DoPostUpdateActions_Always_ClearsAllProbabilisticOutputAndReturnsAffectedObjects()
        {
            // Setup
            var calculation1 = new ProbabilisticPipingCalculationScenario
            {
                Output = PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithIllustrationPoints()
            };
            var calculation2 = new ProbabilisticPipingCalculationScenario
            {
                Output = PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithoutIllustrationPoints()
            };
            var calculation3 = new SemiProbabilisticPipingCalculationScenario
            {
                Output = PipingTestDataGenerator.GetSemiProbabilisticPipingOutput(double.NaN, double.NaN, double.NaN)
            };

            var failureMechanism = new PipingFailureMechanism();

            failureMechanism.CalculationsGroup.Children.AddRange(new ICalculation[]
            {
                calculation1,
                calculation2,
                calculation3,
                new ProbabilisticPipingCalculationScenario()
            });

            var replaceStrategy = new PipingFailureMechanismSectionReplaceStrategy(failureMechanism);

            // Call
            IEnumerable <IObservable> affectedObjects = replaceStrategy.DoPostUpdateActions();

            // Assert
            Assert.IsFalse(calculation1.HasOutput);
            Assert.IsFalse(calculation2.HasOutput);
            Assert.IsTrue(calculation3.HasOutput);
            CollectionAssert.AreEqual(new[]
            {
                calculation1,
                calculation2
            }, affectedObjects);
        }
Exemplo n.º 16
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            SemiProbabilisticPipingOutput output = PipingTestDataGenerator.GetRandomSemiProbabilisticPipingOutput();
            var failureMechanism = new PipingFailureMechanism();

            // Call
            var context = new SemiProbabilisticPipingOutputContext(output, failureMechanism, assessmentSection);

            // Assert
            Assert.IsInstanceOf <WrappedObjectContextBase <SemiProbabilisticPipingOutput> >(context);
            Assert.AreSame(output, context.WrappedData);
            Assert.AreSame(failureMechanism, context.FailureMechanism);
            Assert.AreSame(assessmentSection, context.AssessmentSection);
            mocks.VerifyAll();
        }
Exemplo n.º 17
0
        public void CreateInstance_ValidData_NewPropertiesWithPipingOutputAsData()
        {
            // Setup
            var failureMechanism = new PipingFailureMechanism();

            var mocks = new MockRepository();
            IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);

            mocks.ReplayAll();

            SemiProbabilisticPipingOutput output = PipingTestDataGenerator.GetRandomSemiProbabilisticPipingOutput();
            var context = new SemiProbabilisticPipingOutputContext(output, failureMechanism, assessmentSection);

            // Call
            IObjectProperties objectProperties = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <SemiProbabilisticPipingOutputProperties>(objectProperties);
            Assert.AreSame(output, objectProperties.Data);
            mocks.VerifyAll();
        }
        public void Create_CalculationWithOutputWithFaultTreeIllustrationPoints_ReturnEntityWithOutputAndGeneralResult()
        {
            // Setup
            PartialProbabilisticFaultTreePipingOutput profileSpecificOutput = PipingTestDataGenerator.GetRandomPartialProbabilisticFaultTreePipingOutput();
            PartialProbabilisticFaultTreePipingOutput sectionSpecificOutput = PipingTestDataGenerator.GetRandomPartialProbabilisticFaultTreePipingOutput();
            var output = new ProbabilisticPipingOutput(profileSpecificOutput, sectionSpecificOutput);

            // Call
            ProbabilisticPipingCalculationOutputEntity entity = output.Create();

            // Assert
            Assert.AreEqual(output.ProfileSpecificOutput.Reliability, entity.ProfileSpecificReliability);
            Assert.AreEqual(output.SectionSpecificOutput.Reliability, entity.SectionSpecificReliability);
            GeneralResultEntityTestHelper.AssertGeneralResultPropertyValues(
                profileSpecificOutput.GeneralResult,
                entity.GeneralResultFaultTreeIllustrationPointEntity);
            GeneralResultEntityTestHelper.AssertGeneralResultPropertyValues(
                sectionSpecificOutput.GeneralResult,
                entity.GeneralResultFaultTreeIllustrationPointEntity1);
            Assert.IsNull(entity.GeneralResultSubMechanismIllustrationPointEntity);
            Assert.IsNull(entity.GeneralResultSubMechanismIllustrationPointEntity1);
        }
Exemplo n.º 19
0
        public void ClearIllustrationPoints_CalculationWithOutputWithoutIllustrationPoints_ReturnsFalse()
        {
            // Setup
            var mocks         = new MockRepository();
            var inquiryHelper = mocks.StrictMock <IInquiryHelper>();

            mocks.ReplayAll();

            var calculation = new ProbabilisticPipingCalculationScenario
            {
                Output = PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithoutIllustrationPoints()
            };

            var handler = new ClearIllustrationPointsOfProbabilisticPipingCalculationChangeHandler(inquiryHelper, calculation);

            // Call
            bool result = handler.ClearIllustrationPoints();

            // Assert
            Assert.IsFalse(result);
            mocks.VerifyAll();
        }
        public void ClearStochasticSoilProfileDependentData_CalculationWithOutputWithProfile_ReturnInputAndCalculation()
        {
            // Setup
            PipingFailureMechanism failureMechanism = PipingTestDataGenerator.GetPipingFailureMechanismWithAllCalculationConfigurations();
            IEnumerable <IPipingCalculationScenario <PipingInput> > calculations = failureMechanism.Calculations
                                                                                   .Cast <IPipingCalculationScenario <PipingInput> >();

            var expectedAffectedObjects = new List <IObservable>();

            PipingStochasticSoilProfile profileToDelete = null;

            foreach (IPipingCalculationScenario <PipingInput> calculation in calculations)
            {
                PipingInput input = calculation.InputParameters;
                PipingStochasticSoilProfile currentProfile = input.StochasticSoilProfile;
                if (profileToDelete == null)
                {
                    profileToDelete = currentProfile;
                }

                if (profileToDelete != null && ReferenceEquals(profileToDelete, currentProfile))
                {
                    if (calculation.HasOutput)
                    {
                        expectedAffectedObjects.Add(calculation);
                    }

                    expectedAffectedObjects.Add(input);
                }
            }

            // Call
            IEnumerable <IObservable> affected = PipingDataSynchronizationService.ClearStochasticSoilProfileDependentData(failureMechanism, profileToDelete);

            // Assert
            CollectionAssert.AreEquivalent(expectedAffectedObjects, affected);
            CollectionAssert.IsEmpty(affected.OfType <PipingInput>().Where(a => a.StochasticSoilProfile == null));
            CollectionAssert.IsEmpty(affected.OfType <IPipingCalculationScenario <PipingInput> >().Where(a => a.HasOutput));
        }
        public void ChildNodeObjects_Always_ReturnsCollectionWithOutputObjects(bool hasOutput)
        {
            // Setup
            var calculation = new ProbabilisticPipingCalculationScenario
            {
                Output = hasOutput ? PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithIllustrationPoints() : null
            };
            var context = new ProbabilisticPipingOutputContext(calculation);

            // Call
            object[] children = info.ChildNodeObjects(context).ToArray();

            // Assert
            Assert.AreEqual(2, children.Length);

            var profileSpecificOutputContext = children[0] as ProbabilisticPipingProfileSpecificOutputContext;

            Assert.AreSame(calculation, profileSpecificOutputContext.WrappedData);

            var sectionSpecificOutputContext = children[1] as ProbabilisticPipingSectionSpecificOutputContext;

            Assert.AreSame(calculation, sectionSpecificOutputContext.WrappedData);
        }
        public void ContextMenuStrip_FailureMechanismHasCalculationsWithoutIllustrationPoints_ContextMenuItemClearAllIllustrationPointsDisabledAndToolTipSet()
        {
            // Setup
            using (var treeViewControl = new TreeViewControl())
            {
                var pipingCalculation = new ProbabilisticPipingCalculationScenario
                {
                    Output = PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithoutIllustrationPoints()
                };

                var failureMechanism = new PipingFailureMechanism();
                failureMechanism.CalculationsGroup.Children.Add(pipingCalculation);

                var assessmentSection = mocks.Stub <IAssessmentSection>();
                var context           = new PipingFailureMechanismContext(failureMechanism, assessmentSection);

                var menuBuilder = new CustomItemsOnlyContextMenuBuilder();

                var gui = mocks.Stub <IGui>();
                gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
                gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub <IMainWindow>());
                mocks.ReplayAll();

                plugin.Gui = gui;

                failureMechanism.CalculationsGroup.Children.Add(pipingCalculation);

                // Call
                using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl))
                {
                    // Assert
                    ToolStripItem clearOutputItem = contextMenu.Items[contextMenuClearIllustrationPointsIndex];
                    Assert.IsFalse(clearOutputItem.Enabled);
                    Assert.AreEqual("Er zijn geen berekeningen met illustratiepunten om te wissen.", clearOutputItem.ToolTipText);
                }
            }
        }
        public void ClearReferenceLineDependentData_FullyConfiguredFailureMechanism_RemoveReferenceLineDependentDataAndReturnAffectedObjects()
        {
            // Setup
            PipingFailureMechanism failureMechanism = PipingTestDataGenerator.GetPipingFailureMechanismWithAllCalculationConfigurations();

            object[] expectedRemovedObjects = failureMechanism.Sections.OfType <object>()
                                              .Concat(failureMechanism.SectionResults)
                                              .Concat(failureMechanism.ScenarioConfigurationsPerFailureMechanismSection)
                                              .Concat(failureMechanism.CalculationsGroup.GetAllChildrenRecursive())
                                              .Concat(failureMechanism.StochasticSoilModels)
                                              .Concat(failureMechanism.SurfaceLines)
                                              .ToArray();

            // Call
            ClearResults results = PipingDataSynchronizationService.ClearReferenceLineDependentData(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.Sections);
            CollectionAssert.IsEmpty(failureMechanism.SectionResults);
            CollectionAssert.IsEmpty(failureMechanism.ScenarioConfigurationsPerFailureMechanismSection);
            CollectionAssert.IsEmpty(failureMechanism.CalculationsGroup.Children);
            CollectionAssert.IsEmpty(failureMechanism.StochasticSoilModels);
            CollectionAssert.IsEmpty(failureMechanism.SurfaceLines);

            IObservable[] array = results.ChangedObjects.ToArray();
            Assert.AreEqual(6, array.Length);
            CollectionAssert.Contains(array, failureMechanism);
            CollectionAssert.Contains(array, failureMechanism.SectionResults);
            CollectionAssert.Contains(array, failureMechanism.ScenarioConfigurationsPerFailureMechanismSection);
            CollectionAssert.Contains(array, failureMechanism.CalculationsGroup);
            CollectionAssert.Contains(array, failureMechanism.StochasticSoilModels);
            CollectionAssert.Contains(array, failureMechanism.SurfaceLines);

            CollectionAssert.AreEquivalent(expectedRemovedObjects, results.RemovedObjects);
        }
        public void SemiProbabilisticGetInitialFailureMechanismResultProbability_MultipleScenarios_ReturnsValueBasedOnRelevantScenarios()
        {
            // Setup
            FailureMechanismSection section   = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
            var failureMechanismSectionResult = new AdoptableWithProfileProbabilityFailureMechanismSectionResult(section);

            var pipingCalculationScenario1 =
                SemiProbabilisticPipingCalculationTestFactory.CreateCalculation <SemiProbabilisticPipingCalculationScenario>(section);
            var pipingCalculationScenario2 =
                SemiProbabilisticPipingCalculationTestFactory.CreateCalculation <SemiProbabilisticPipingCalculationScenario>(section);
            var pipingCalculationScenario3 =
                SemiProbabilisticPipingCalculationTestFactory.CreateCalculation <SemiProbabilisticPipingCalculationScenario>(section);

            pipingCalculationScenario1.IsRelevant   = true;
            pipingCalculationScenario1.Contribution = (RoundedDouble)0.2111;
            pipingCalculationScenario1.Output       = PipingTestDataGenerator.GetSemiProbabilisticPipingOutput(1.1, 2.2, 3.3);

            pipingCalculationScenario2.IsRelevant   = true;
            pipingCalculationScenario2.Contribution = (RoundedDouble)0.7889;
            pipingCalculationScenario2.Output       = PipingTestDataGenerator.GetSemiProbabilisticPipingOutput(4.4, 5.5, 6.6);

            pipingCalculationScenario3.IsRelevant = false;

            SemiProbabilisticPipingCalculationScenario[] calculations =
            {
                pipingCalculationScenario1,
                pipingCalculationScenario2,
                pipingCalculationScenario3
            };

            // Call
            double initialFailureMechanismResultProbability = failureMechanismSectionResult.GetInitialFailureMechanismResultProbability(calculations, 0.1);

            // Assert
            Assert.AreEqual(4.2467174336864661e-7, initialFailureMechanismResultProbability);
        }
Exemplo n.º 25
0
        public void RequireConfirmation_ProbabilisticCalculationsWithOutput_ReturnsTrue()
        {
            // Setup
            var mocks         = new MockRepository();
            var inquiryHelper = mocks.Stub <IInquiryHelper>();

            mocks.ReplayAll();

            var failureMechanism = new PipingFailureMechanism();

            failureMechanism.CalculationsGroup.Children.Add(new ProbabilisticPipingCalculationScenario
            {
                Output = PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithIllustrationPoints()
            });

            var changeHandler = new PipingFailureMechanismCalculationChangeHandler(failureMechanism, string.Empty, inquiryHelper);

            // Call
            bool requireConfirmation = changeHandler.RequireConfirmation();

            // Assert
            Assert.IsTrue(requireConfirmation);
            mocks.VerifyAll();
        }
Exemplo n.º 26
0
        public void CalculateProfileProbability_MultipleScenarios_ReturnsValueBasedOnRelevantScenarios()
        {
            // Setup
            FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
            var sectionResult = new AdoptableWithProfileProbabilityFailureMechanismSectionResult(section);

            var calculationScenario1 = SemiProbabilisticPipingCalculationTestFactory.CreateCalculation <SemiProbabilisticPipingCalculationScenario>(section);
            var calculationScenario2 = SemiProbabilisticPipingCalculationTestFactory.CreateCalculation <SemiProbabilisticPipingCalculationScenario>(section);
            var calculationScenario3 = SemiProbabilisticPipingCalculationTestFactory.CreateCalculation <SemiProbabilisticPipingCalculationScenario>(section);

            calculationScenario1.IsRelevant   = true;
            calculationScenario1.Contribution = (RoundedDouble)0.2111;
            calculationScenario1.Output       = PipingTestDataGenerator.GetSemiProbabilisticPipingOutput(1.1, 2.2, 3.3);

            calculationScenario2.IsRelevant   = true;
            calculationScenario2.Contribution = (RoundedDouble)0.7889;
            calculationScenario2.Output       = PipingTestDataGenerator.GetSemiProbabilisticPipingOutput(4.4, 5.5, 6.6);

            calculationScenario3.IsRelevant = false;

            SemiProbabilisticPipingCalculationScenario[] calculations =
            {
                calculationScenario1,
                calculationScenario2,
                calculationScenario3
            };

            var strategy = new SemiProbabilisticPipingFailureMechanismSectionResultCalculateProbabilityStrategy(
                sectionResult, calculations, new PipingFailureMechanism(), new AssessmentSectionStub());

            // Call
            double profileProbability = strategy.CalculateProfileProbability();

            // Assert
            Assert.AreEqual(9.2969543564512289E-16, profileProbability);
        }
Exemplo n.º 27
0
        public void GetProperties_WithData_ReturnExpectedValues()
        {
            // Setup
            PartialProbabilisticPipingOutput <TestTopLevelIllustrationPoint> output = PipingTestDataGenerator.GetRandomPartialProbabilisticPipingOutput();

            // Call
            var properties = new TestProbabilisticPipingOutputProperties(output);

            // Assert
            Assert.AreEqual(ProbabilityFormattingHelper.Format(StatisticsConverter.ReliabilityToProbability(output.Reliability)), properties.Probability);
            Assert.AreEqual(output.Reliability, properties.Reliability, properties.Reliability.GetAccuracy());
        }
Exemplo n.º 28
0
        public void Constructor_WithData_ExpectedValues()
        {
            // Setup
            PartialProbabilisticPipingOutput <TestTopLevelIllustrationPoint> output = PipingTestDataGenerator.GetRandomPartialProbabilisticPipingOutput();

            // Call
            var properties = new TestProbabilisticPipingOutputProperties(output);

            // Assert
            Assert.IsInstanceOf <ObjectProperties <IPartialProbabilisticPipingOutput> >(properties);
            Assert.AreSame(output, properties.Data);
        }
Exemplo n.º 29
0
        public void Constructor_WithData_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            PartialProbabilisticPipingOutput <TestTopLevelIllustrationPoint> output = PipingTestDataGenerator.GetRandomPartialProbabilisticPipingOutput(null);

            // Call
            var properties = new TestProbabilisticPipingOutputProperties(output);

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(2, dynamicProperties.Count);

            PropertyDescriptor probabilityProperty = dynamicProperties[probabilityPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(probabilityProperty,
                                                                            resultCategoryName,
                                                                            "Faalkans [1/jaar]",
                                                                            "De kans dat het faalmechanisme optreedt voor deze berekening.",
                                                                            true);

            PropertyDescriptor reliabilityProperty = dynamicProperties[reliabilityPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(reliabilityProperty,
                                                                            resultCategoryName,
                                                                            "Betrouwbaarheidsindex faalkans [-]",
                                                                            "De betrouwbaarheidsindex van de faalkans voor deze berekening.",
                                                                            true);
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            PartialProbabilisticPipingOutput <TestTopLevelIllustrationPoint> sectionSpecificOutput = PipingTestDataGenerator.GetRandomPartialProbabilisticPipingOutput();
            PartialProbabilisticPipingOutput <TestTopLevelIllustrationPoint> profileSpecificOutput = PipingTestDataGenerator.GetRandomPartialProbabilisticPipingOutput();

            // Call
            var output = new ProbabilisticPipingOutput(sectionSpecificOutput, profileSpecificOutput);

            // Assert
            Assert.IsInstanceOf <CloneableObservable>(output);
            Assert.IsInstanceOf <ICalculationOutput>(output);
            Assert.AreSame(sectionSpecificOutput, output.SectionSpecificOutput);
            Assert.AreSame(profileSpecificOutput, output.ProfileSpecificOutput);
        }