예제 #1
0
        public void Create_ResultsPerFailureMechanismNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => CombinedFailureMechanismSectionAssemblyCreator.Create(null, Array.Empty <FailureMechanismSectionWithCategory>());

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

            Assert.AreEqual("resultsPerFailureMechanism", exception.ParamName);
        }
예제 #2
0
        public void Create_CombinedSectionResultsNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => CombinedFailureMechanismSectionAssemblyCreator.Create(Array.Empty <FailureMechanismSectionList>(), null);

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

            Assert.AreEqual("combinedSectionResults", exception.ParamName);
        }
예제 #3
0
        public void Create_WithResult_ReturnCombinedFailureMechanismSectionAssemblies()
        {
            // Setup
            var random = new Random(21);

            var sections = new[]
            {
                new Tuple <double, double>(0, 2),
                new Tuple <double, double>(2, 5),
                new Tuple <double, double>(5, random.NextDouble(5, 6))
            };

            var failureMechanismResults = new[]
            {
                new FailureMechanismSectionList(new[]
                {
                    CreateCategory(sections[0], random),
                    CreateCategory(sections[1], random),
                    CreateCategory(sections[2], random)
                }),
                new FailureMechanismSectionList(new[]
                {
                    CreateCategory(sections[0], random),
                    CreateCategory(sections[1], random),
                    CreateCategory(sections[2], random)
                })
            };

            FailureMechanismSectionWithCategory[] combinedResults =
            {
                CreateCategory(sections[0], random),
                CreateCategory(sections[1], random),
                CreateCategory(sections[2], random)
            };

            // Call
            IEnumerable <CombinedFailureMechanismSectionAssembly> results = CombinedFailureMechanismSectionAssemblyCreator.Create(failureMechanismResults, combinedResults);

            // Assert
            CombinedFailureMechanismSectionAssemblyAssert.AssertAssembly(failureMechanismResults, combinedResults, results);
        }
예제 #4
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);
            }
        }