コード例 #1
0
        public void CreateExportableFailureMechanism_AssessmentSectionNull_ThrowsArgumentNullException()
        {
            // Setup
            var random = new Random(21);

            // Call
            void Call() => ExportableFailureMechanismFactory.CreateExportableFailureMechanism <TestFailureMechanism, TestFailureMechanismSectionResult>(
                new TestFailureMechanism(), null, (fm, section) => null, (sr, fm, section) => null, random.NextEnumValue <ExportableFailureMechanismType>());

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

            Assert.AreEqual("assessmentSection", exception.ParamName);
        }
コード例 #2
0
        public void CreateExportableFailureMechanism_AssembleFailureMechanismFuncNull_ThrowsArgumentNullException()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var random = new Random(21);

            // Call
            void Call() => ExportableFailureMechanismFactory.CreateExportableFailureMechanism <TestFailureMechanism, TestFailureMechanismSectionResult>(
                new TestFailureMechanism(), assessmentSection, null, (sr, fm, section) => null, random.NextEnumValue <ExportableFailureMechanismType>());

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

            Assert.AreEqual("assembleFailureMechanismFunc", exception.ParamName);
            mocks.VerifyAll();
        }
コード例 #3
0
        public void CreateExportableFailureMechanism_WithValidData_ReturnsExportableFailureMechanism()
        {
            // Setup
            var random           = new Random(21);
            var failureMechanism = new TestFailureMechanism();

            FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(2, 10));
            var assessmentSection = new AssessmentSectionStub();

            double probability    = random.NextDouble();
            var    assemblyMethod = random.NextEnumValue <AssemblyMethod>();
            FailureMechanismSectionAssemblyResultWrapper expectedSectionOutput = FailureMechanismSectionAssemblyResultWrapperTestFactory.Create();

            var failureMechanismType = random.NextEnumValue <ExportableFailureMechanismType>();

            // Call
            ExportableFailureMechanism exportableFailureMechanism =
                ExportableFailureMechanismFactory.CreateExportableFailureMechanism <TestFailureMechanism, TestFailureMechanismSectionResult>(
                    failureMechanism, assessmentSection, (fm, section) => new FailureMechanismAssemblyResultWrapper(probability, assemblyMethod),
                    (sr, fm, section) => expectedSectionOutput, failureMechanismType);

            // Assert
            Assert.AreEqual(failureMechanismType, exportableFailureMechanism.FailureMechanismType);
            Assert.AreEqual(failureMechanism.Code, exportableFailureMechanism.Code);

            ExportableFailureMechanismAssemblyResult exportableFailureMechanismAssembly = exportableFailureMechanism.FailureMechanismAssembly;

            Assert.AreEqual(probability, exportableFailureMechanismAssembly.Probability);
            Assert.AreEqual(ExportableAssemblyMethodFactory.Create(assemblyMethod), exportableFailureMechanismAssembly.AssemblyMethod);

            IEnumerable <ExportableFailureMechanismSection> exportableFailureMechanismSections = exportableFailureMechanism.SectionAssemblyResults
                                                                                                 .Select(sar => sar.FailureMechanismSection);

            ExportableFailureMechanismSectionTestHelper.AssertExportableFailureMechanismSections(failureMechanism.Sections, exportableFailureMechanismSections);

            ExportableFailureMechanismSectionAssemblyResultTestHelper.AssertExportableFailureMechanismSectionResults(
                expectedSectionOutput, exportableFailureMechanismSections, exportableFailureMechanism.SectionAssemblyResults);
        }