Пример #1
0
        public void AssembleSection_CalculatorThrowsException_ThrowsAssemblyException()
        {
            // Setup
            var failureMechanism            = new TestCalculatableFailureMechanism();
            FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
            var sectionResult = new AdoptableFailureMechanismSectionResult(section);

            var assessmentSection = new AssessmentSectionStub();

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
                calculator.ThrowExceptionOnCalculate = true;

                // Call
                void Call() => StructuresFailureMechanismAssemblyFactory.AssembleSection <TestStructuresInput>(
                    sectionResult, failureMechanism, assessmentSection);

                // Assert
                var       exception      = Assert.Throws <AssemblyException>(Call);
                Exception innerException = exception.InnerException;
                Assert.IsInstanceOf <FailureMechanismSectionAssemblyCalculatorException>(innerException);
                Assert.AreEqual(innerException.Message, exception.Message);
            }
        }
Пример #2
0
        public void AssembleSection_AssessmentSectionNull_ThrowsArgumentNullException()
        {
            // Setup
            FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
            var sectionResult = new AdoptableFailureMechanismSectionResult(section);

            var failureMechanism = new TestCalculatableFailureMechanism();

            // Call
            void Call() => StructuresFailureMechanismAssemblyFactory.AssembleSection <TestStructuresInput>(sectionResult, failureMechanism, null);

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

            Assert.AreEqual("assessmentSection", exception.ParamName);
        }
Пример #3
0
        public void AssembleSection_SectionResultNull_ThrowsArgumentNullException()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new TestCalculatableFailureMechanism();

            // Call
            void Call() => StructuresFailureMechanismAssemblyFactory.AssembleSection <TestStructuresInput>(null, failureMechanism, assessmentSection);

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

            Assert.AreEqual("sectionResult", exception.ParamName);

            mocks.VerifyAll();
        }
        protected override void CreateMapData()
        {
            base.CreateMapData();

            MapDataCollection sectionsMapDataCollection = RiskeerMapDataFactory.CreateSectionsMapDataCollection();

            sectionsMapData           = RiskeerMapDataFactory.CreateFailureMechanismSectionsMapData();
            sectionsStartPointMapData = RiskeerMapDataFactory.CreateFailureMechanismSectionsStartPointMapData();
            sectionsEndPointMapData   = RiskeerMapDataFactory.CreateFailureMechanismSectionsEndPointMapData();

            assemblyResultsMapLayer = new CalculatableFailureMechanismSectionResultsMapLayer <ClosingStructuresFailureMechanism, AdoptableFailureMechanismSectionResult, ClosingStructuresInput>(
                FailureMechanism, sr => StructuresFailureMechanismAssemblyFactory.AssembleSection <ClosingStructuresInput>(sr, FailureMechanism, AssessmentSection).AssemblyResult);

            sectionsMapDataCollection.Add(sectionsMapData);
            sectionsMapDataCollection.Add(sectionsStartPointMapData);
            sectionsMapDataCollection.Add(sectionsEndPointMapData);
            MapDataCollection.Insert(1, sectionsMapDataCollection);

            MapDataCollection.Insert(2, assemblyResultsMapLayer.MapData);
        }
Пример #5
0
        public void AssembleSection_FailureMechanismNull_ThrowsArgumentNullException()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
            var sectionResult = new AdoptableFailureMechanismSectionResult(section);

            // Call
            void Call() => StructuresFailureMechanismAssemblyFactory.AssembleSection <TestStructuresInput>(sectionResult, null, assessmentSection);

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

            Assert.AreEqual("failureMechanism", exception.ParamName);

            mocks.VerifyAll();
        }
        protected override AdoptableFailureMechanismSectionResultRow CreateFailureMechanismSectionResultRow(AdoptableFailureMechanismSectionResult sectionResult)
        {
            StructuresCalculationScenario <TStructuresInput>[] calculationScenarios = FailureMechanism.Calculations
                                                                                      .OfType <StructuresCalculationScenario <TStructuresInput> >()
                                                                                      .ToArray();

            return(new AdoptableFailureMechanismSectionResultRow(
                       sectionResult,
                       () => sectionResult.GetInitialFailureMechanismResultProbability(calculationScenarios),
                       CreateErrorProvider(sectionResult, calculationScenarios),
                       () => StructuresFailureMechanismAssemblyFactory.AssembleSection <TStructuresInput>(sectionResult, FailureMechanism, AssessmentSection),
                       new AdoptableFailureMechanismSectionResultRow.ConstructionProperties
            {
                InitialFailureMechanismResultTypeIndex = initialFailureMechanismResultTypeIndex,
                InitialFailureMechanismResultSectionProbabilityIndex = initialFailureMechanismResultSectionProbabilityIndex,
                FurtherAnalysisTypeIndex = furtherAnalysisTypeIndex,
                RefinedSectionProbabilityIndex = refinedSectionProbabilityIndex,
                SectionProbabilityIndex = sectionProbabilityIndex,
                AssemblyGroupIndex = assemblyGroupIndex
            }));
        }
Пример #7
0
        public void AssembleSection_CalculatorRan_ReturnsExpectedOutput()
        {
            // Setup
            var failureMechanism            = new TestCalculatableFailureMechanism();
            FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
            var sectionResult = new AdoptableFailureMechanismSectionResult(section);

            var assessmentSection = new AssessmentSectionStub();

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;

                // Call
                FailureMechanismSectionAssemblyResultWrapper result = StructuresFailureMechanismAssemblyFactory.AssembleSection <TestStructuresInput>(
                    sectionResult, failureMechanism, assessmentSection);

                // Assert
                Assert.AreSame(calculator.FailureMechanismSectionAssemblyResultOutput, result);
            }
        }
Пример #8
0
        public void AssembleSection_WithInput_SetsInputOnCalculator()
        {
            // Setup
            var random = new Random(21);

            FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
            var sectionResult = new AdoptableFailureMechanismSectionResult(section)
            {
                IsRelevant = random.NextBoolean(),
                InitialFailureMechanismResultType = AdoptableInitialFailureMechanismResultType.Manual,
                FurtherAnalysisType       = random.NextEnumValue <FailureMechanismSectionResultFurtherAnalysisType>(),
                RefinedSectionProbability = random.NextDouble()
            };

            var failureMechanism  = new TestCalculatableFailureMechanism();
            var assessmentSection = new AssessmentSectionStub();

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;

                // Call
                StructuresFailureMechanismAssemblyFactory.AssembleSection <TestStructuresInput>(sectionResult, failureMechanism, assessmentSection);

                // Assert
                FailureMechanismSectionAssemblyInput calculatorInput = calculator.FailureMechanismSectionAssemblyInput;
                FailureMechanismContribution         failureMechanismContribution = assessmentSection.FailureMechanismContribution;
                Assert.AreEqual(failureMechanismContribution.SignalFloodingProbability, calculatorInput.SignalFloodingProbability);
                Assert.AreEqual(failureMechanismContribution.MaximumAllowableFloodingProbability, calculatorInput.MaximumAllowableFloodingProbability);

                Assert.AreEqual(sectionResult.IsRelevant, calculatorInput.IsRelevant);
                Assert.IsTrue(calculatorInput.HasProbabilitySpecified);

                Assert.AreEqual(sectionResult.ManualInitialFailureMechanismResultSectionProbability, calculatorInput.InitialSectionProbability);
                Assert.AreEqual(sectionResult.FurtherAnalysisType, calculatorInput.FurtherAnalysisType);
                Assert.AreEqual(sectionResult.RefinedSectionProbability, calculatorInput.RefinedSectionProbability);
            }
        }
        /// <summary>
        /// Assembles the failure mechanism based on its input arguments.
        /// </summary>
        /// <param name="failureMechanism">The <see cref="StabilityPointStructuresFailureMechanism"/> to assemble.</param>
        /// <param name="assessmentSection">The <see cref="IAssessmentSection"/> the <paramref name="failureMechanism"/>
        /// belongs to.</param>
        /// <returns>A <see cref="FailureMechanismAssemblyResultWrapper"/> with the assembly result.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any argument is <c>null</c>.</exception>
        /// <exception cref="AssemblyException">Thrown when the failure mechanism could not be assembled.</exception>
        public static FailureMechanismAssemblyResultWrapper AssembleFailureMechanism(StabilityPointStructuresFailureMechanism failureMechanism,
                                                                                     IAssessmentSection assessmentSection)
        {
            if (failureMechanism == null)
            {
                throw new ArgumentNullException(nameof(failureMechanism));
            }

            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            Func <AdoptableFailureMechanismSectionResult, FailureMechanismSectionAssemblyResultWrapper> performSectionAssemblyFunc = sr =>
                                                                                                                                     StructuresFailureMechanismAssemblyFactory.AssembleSection <StabilityPointStructuresInput>(sr, failureMechanism, assessmentSection);

            return(FailureMechanismAssemblyResultFactory.AssembleFailureMechanism(
                       failureMechanism.GeneralInput.N,
                       failureMechanism.SectionResults.Select(sr => AssemblyToolHelper.AssembleFailureMechanismSection(sr, performSectionAssemblyFunc))
                       .ToArray(),
                       failureMechanism.GeneralInput.ApplyLengthEffectInSection,
                       failureMechanism.AssemblyResult));
        }