예제 #1
0
        public void Create_FailureMechanismSectionsCollectionNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => FailureMechanismSectionListCreator.Create(null);

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

            Assert.AreEqual("failureMechanismSectionsCollection", exception.ParamName);
        }
예제 #2
0
        public void Create_WithFailureMechanism_ReturnFailureMechanismSectionLists()
        {
            // Setup
            var random = new Random(21);
            var combinedAssemblyFailureMechanismInputs = new[]
            {
                new[]
                {
                    new CombinedAssemblyFailureMechanismSection(0, 1, random.NextEnumValue <FailureMechanismSectionAssemblyGroup>()),
                    new CombinedAssemblyFailureMechanismSection(1, 2, random.NextEnumValue <FailureMechanismSectionAssemblyGroup>())
                }
            };

            // Call
            IEnumerable <FailureMechanismSectionList> failureMechanismSectionLists = FailureMechanismSectionListCreator.Create(combinedAssemblyFailureMechanismInputs);

            // Assert
            CombinedFailureMechanismSectionsInputAssert.AssertCombinedFailureMechanismInput(combinedAssemblyFailureMechanismInputs, failureMechanismSectionLists);
        }
예제 #3
0
        public CombinedFailureMechanismSectionAssemblyResultWrapper AssembleCombinedFailureMechanismSections(
            IEnumerable <IEnumerable <CombinedAssemblyFailureMechanismSection> > input, double assessmentSectionLength)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            try
            {
                ICommonFailureMechanismSectionAssembler kernel = factory.CreateCombinedFailureMechanismSectionAssemblyKernel();

                IEnumerable <FailureMechanismSectionList> failureMechanismSections = FailureMechanismSectionListCreator.Create(input);
                FailureMechanismSectionList commonSections = kernel.FindGreatestCommonDenominatorSectionsBoi3A1(
                    failureMechanismSections, assessmentSectionLength);

                FailureMechanismSectionList[] failureMechanismResults = failureMechanismSections.Select(fmsl => kernel.TranslateFailureMechanismResultsToCommonSectionsBoi3B1(
                                                                                                            fmsl, commonSections))
                                                                        .ToArray();

                IEnumerable <FailureMechanismSectionWithCategory> combinedSectionResults =
                    kernel.DetermineCombinedResultPerCommonSectionBoi3C1(failureMechanismResults, false);

                return(new CombinedFailureMechanismSectionAssemblyResultWrapper(
                           CombinedFailureMechanismSectionAssemblyCreator.Create(failureMechanismResults, combinedSectionResults),
                           AssemblyMethod.BOI3A1, AssemblyMethod.BOI3B1, AssemblyMethod.BOI3C1));
            }
            catch (AssemblyException e)
            {
                throw new AssessmentSectionAssemblyCalculatorException(AssemblyErrorMessageCreator.CreateErrorMessage(e.Errors), e);
            }
            catch (Exception e)
            {
                throw new AssessmentSectionAssemblyCalculatorException(AssemblyErrorMessageCreator.CreateGenericErrorMessage(), e);
            }
        }