Example #1
0
        public FailureMechanismAssemblyResultWrapper Assemble(double failureMechanismN, IEnumerable <RiskeerFailureMechanismSectionAssemblyResult> sectionAssemblyResults,
                                                              bool applySectionLengthEffect)
        {
            if (sectionAssemblyResults == null)
            {
                throw new ArgumentNullException(nameof(sectionAssemblyResults));
            }

            try
            {
                IFailureMechanismResultAssembler kernel = factory.CreateFailureMechanismAssemblyKernel();

                FailureMechanismAssemblyResult result;
                if (applySectionLengthEffect)
                {
                    result = kernel.CalculateFailureMechanismFailureProbabilityWithLengthEffectBoi1A2(
                        failureMechanismN, sectionAssemblyResults.Select(FailureMechanismAssemblyCalculatorInputCreator.CreateResultWithProfileAndSectionProbabilities),
                        false);
                    return(new FailureMechanismAssemblyResultWrapper(result.Probability, AssemblyMethod.BOI1A2));
                }

                result = kernel.CalculateFailureMechanismFailureProbabilityBoi1A1(
                    failureMechanismN, sectionAssemblyResults.Select(sr => AssemblyCalculatorInputCreator.CreateProbability(sr.SectionProbability)),
                    false);
                return(new FailureMechanismAssemblyResultWrapper(result.Probability, AssemblyMethod.BOI1A1));
            }
            catch (AssemblyException e)
            {
                throw new FailureMechanismAssemblyCalculatorException(AssemblyErrorMessageCreator.CreateErrorMessage(e.Errors), e);
            }
            catch (Exception e)
            {
                throw new FailureMechanismAssemblyCalculatorException(AssemblyErrorMessageCreator.CreateGenericErrorMessage(), e);
            }
        }
        public void CreateFailureMechanismAssemblyKernel_Always_ReturnsKernelFailureMechanismResultAssembler()
        {
            // Setup
            IAssemblyToolKernelFactory factory = AssemblyToolKernelFactory.Instance;

            // Call
            IFailureMechanismResultAssembler kernel = factory.CreateFailureMechanismAssemblyKernel();

            // Assert
            Assert.IsInstanceOf <FailureMechanismResultAssembler>(kernel);
        }