示例#1
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);
        }
        public void AssembleCombinedFailureMechanismSections_WithValidInput_InputCorrectlySetToKernel()
        {
            // Setup
            var random = new Random(39);
            var input  = new[]
            {
                new[]
                {
                    new CombinedAssemblyFailureMechanismSection(0, 1, random.NextEnumValue <FailureMechanismSectionAssemblyGroup>())
                }
            };
            double assessmentSectionLength = random.NextDouble();

            using (new AssemblyToolKernelFactoryConfig())
            {
                var factory = (TestAssemblyToolKernelFactory)AssemblyToolKernelFactory.Instance;
                CombinedFailureMechanismSectionAssemblyKernelStub kernel = factory.LastCreatedCombinedFailureMechanismSectionAssemblyKernel;

                var calculator = new AssessmentSectionAssemblyCalculator(factory);

                // Call
                calculator.AssembleCombinedFailureMechanismSections(input, assessmentSectionLength);

                // Assert
                CombinedFailureMechanismSectionsInputAssert.AssertCombinedFailureMechanismInput(input, kernel.FailureMechanismSectionLists);
                Assert.AreEqual(assessmentSectionLength, kernel.AssessmentSectionLength);
                Assert.IsTrue(kernel.CalculatedCommonSections);

                Assert.AreSame(kernel.FailureMechanismSectionLists.Single(), kernel.FailureMechanismSectionList);
                Assert.AreSame(kernel.CommonSections, kernel.CommonSectionsInput);
                Assert.IsTrue(kernel.CalculatedCommonSectionResults);

                Assert.AreEqual(1, kernel.FailureMechanismResultsInput.Count());
                Assert.AreSame(kernel.FailureMechanismResult, kernel.FailureMechanismResultsInput.First());
                Assert.IsFalse(kernel.PartialAssembly);
                Assert.IsTrue(kernel.CalculatedSectionResults);
            }
        }