public void FailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized()
        {
            // Setup
            FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1");

            var failureMechanism = new TestNonAdoptableFailureMechanism();

            FailureMechanismTestHelper.SetSections(failureMechanism, new[]
            {
                section
            });

            // Call
            using (new AssemblyToolCalculatorFactoryConfig())
                using (ShowFailureMechanismResultsView(failureMechanism))
                {
                    DataGridView dataGridView = GetDataGridView();

                    // Assert
                    DataGridViewRowCollection rows = dataGridView.Rows;
                    Assert.AreEqual(1, rows.Count);

                    DataGridViewCellCollection cells = rows[0].Cells;
                    Assert.AreEqual(columnCount, cells.Count);
                    Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue);
                    Assert.AreEqual(true, cells[isRelevantIndex].Value);
                    Assert.AreEqual(NonAdoptableInitialFailureMechanismResultType.Manual, cells[initialFailureMechanismResultTypeIndex].Value);
                    Assert.AreEqual("-", cells[initialFailureMechanismResultSectionProbabilityIndex].FormattedValue);
                    Assert.AreEqual(FailureMechanismSectionResultFurtherAnalysisType.NotNecessary, cells[furtherAnalysisTypeIndex].Value);
                    Assert.AreEqual("-", cells[refinedSectionProbabilityIndex].FormattedValue);
                    Assert.AreEqual("1/10", cells[sectionProbabilityIndex].FormattedValue);
                    Assert.AreEqual("+I", cells[assemblyGroupIndex].FormattedValue);
                }
        }
        private NonAdoptableFailureMechanismResultView <TestNonAdoptableFailureMechanism> ShowFailureMechanismResultsView(
            TestNonAdoptableFailureMechanism failureMechanism, IAssessmentSection assessmentSection,
            Func <TestNonAdoptableFailureMechanism, IAssessmentSection, FailureMechanismAssemblyResultWrapper> performFailureMechanismAssemblyFunc)
        {
            var failureMechanismResultView = new NonAdoptableFailureMechanismResultView <TestNonAdoptableFailureMechanism>(
                failureMechanism.SectionResults,
                failureMechanism,
                assessmentSection,
                performFailureMechanismAssemblyFunc);

            testForm.Controls.Add(failureMechanismResultView);
            testForm.Show();

            return(failureMechanismResultView);
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new TestNonAdoptableFailureMechanism();

            // Call
            using (var view = new NonAdoptableFailureMechanismResultView <TestNonAdoptableFailureMechanism>(
                       failureMechanism.SectionResults, failureMechanism, assessmentSection, (fm, ass) => new FailureMechanismAssemblyResultWrapper(double.NaN, AssemblyMethod.Manual)))
            {
                // Assert
                Assert.IsInstanceOf <FailureMechanismResultView <NonAdoptableFailureMechanismSectionResult,
                                                                 NonAdoptableFailureMechanismSectionResultRow,
                                                                 TestNonAdoptableFailureMechanism> >(view);
                Assert.IsNull(view.Data);
                Assert.AreSame(failureMechanism, view.FailureMechanism);
            }

            mocks.VerifyAll();
        }
 private NonAdoptableFailureMechanismResultView <TestNonAdoptableFailureMechanism> ShowFailureMechanismResultsView(
     TestNonAdoptableFailureMechanism failureMechanism, IAssessmentSection assessmentSection)
 {
     return(ShowFailureMechanismResultsView(failureMechanism, assessmentSection, (fm, section) => new FailureMechanismAssemblyResultWrapper(1.2345, AssemblyMethod.Manual)));
 }
 private NonAdoptableFailureMechanismResultView <TestNonAdoptableFailureMechanism> ShowFailureMechanismResultsView(TestNonAdoptableFailureMechanism failureMechanism)
 {
     return(ShowFailureMechanismResultsView(failureMechanism, new AssessmentSectionStub()));
 }