public void CreateAssessmentSectionAssemblyKernel_Always_ReturnsKernelAssessmentGradeAssembler()
        {
            // Setup
            IAssemblyToolKernelFactory factory = AssemblyToolKernelFactory.Instance;

            // Call
            IAssessmentGradeAssembler kernel = factory.CreateAssessmentSectionAssemblyKernel();

            // Assert
            Assert.IsInstanceOf <AssessmentGradeAssembler>(kernel);
        }
示例#2
0
        public AssessmentSectionAssemblyResultWrapper AssembleAssessmentSection(IEnumerable <double> failureMechanismProbabilities,
                                                                                double maximumAllowableFloodingProbability,
                                                                                double signalFloodingProbability)
        {
            if (failureMechanismProbabilities == null)
            {
                throw new ArgumentNullException(nameof(failureMechanismProbabilities));
            }

            try
            {
                ICategoryLimitsCalculator categoryLimitsKernel = factory.CreateAssemblyGroupsKernel();
                CategoriesList <AssessmentSectionCategory> assessmentSectionCategories = categoryLimitsKernel.CalculateAssessmentSectionCategoryLimitsBoi21(
                    new AssessmentSection(AssemblyCalculatorInputCreator.CreateProbability(signalFloodingProbability),
                                          AssemblyCalculatorInputCreator.CreateProbability(maximumAllowableFloodingProbability)));

                IAssessmentGradeAssembler assessmentSectionAssemblyKernel = factory.CreateAssessmentSectionAssemblyKernel();
                IEnumerable <Probability> probabilities = failureMechanismProbabilities.Select(AssemblyCalculatorInputCreator.CreateProbability)
                                                          .ToArray();

                Probability      assemblyProbability = assessmentSectionAssemblyKernel.CalculateAssessmentSectionFailureProbabilityBoi2A1(probabilities, false);
                EAssessmentGrade assemblyCategory    = assessmentSectionAssemblyKernel.DetermineAssessmentGradeBoi2B1(assemblyProbability, assessmentSectionCategories);

                return(new AssessmentSectionAssemblyResultWrapper(
                           new AssessmentSectionAssemblyResult(assemblyProbability,
                                                               AssessmentSectionAssemblyGroupCreator.CreateAssessmentSectionAssemblyGroup(assemblyCategory)),
                           AssemblyMethod.BOI2A1, AssemblyMethod.BOI2B1));
            }
            catch (AssemblyException e)
            {
                throw new AssessmentSectionAssemblyCalculatorException(AssemblyErrorMessageCreator.CreateErrorMessage(e.Errors), e);
            }
            catch (Exception e)
            {
                throw new AssessmentSectionAssemblyCalculatorException(AssemblyErrorMessageCreator.CreateGenericErrorMessage(), e);
            }
        }