public void CreateCalculateStrategy_WithProbabilisticConfigurations_ReturnsExpectedStrategy(
            PipingFailureMechanism failureMechanism, PipingScenarioConfigurationPerFailureMechanismSectionType configurationType)
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();

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

            PipingScenarioConfigurationPerFailureMechanismSection scenarioConfigurationPerFailureMechanismSection =
                failureMechanism.ScenarioConfigurationsPerFailureMechanismSection.Single();

            scenarioConfigurationPerFailureMechanismSection.ScenarioConfigurationType = configurationType;

            // Call
            IFailureMechanismSectionResultCalculateProbabilityStrategy strategy =
                PipingFailureMechanismSectionResultCalculateProbabilityStrategyFactory.CreateCalculateStrategy(
                    failureMechanism.SectionResults.Single(), failureMechanism, assessmentSection);

            // Assert
            Assert.IsInstanceOf <ProbabilisticPipingFailureMechanismSectionResultCalculateProbabilityStrategy>(strategy);
        }
        public void FailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized(
            PipingScenarioConfigurationType scenarioConfigurationType,
            PipingScenarioConfigurationPerFailureMechanismSectionType scenarioConfigurationPerFailureMechanismSectionType,
            string probability)
        {
            // Setup
            FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1");

            var failureMechanism = new PipingFailureMechanism
            {
                ScenarioConfigurationType = scenarioConfigurationType
            };

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

            failureMechanism.ScenarioConfigurationsPerFailureMechanismSection.First().ScenarioConfigurationType = scenarioConfigurationPerFailureMechanismSectionType;

            failureMechanism.CalculationsGroup.Children.Add(
                SemiProbabilisticPipingCalculationTestFactory.CreateCalculation <SemiProbabilisticPipingCalculationScenario>(section));
            failureMechanism.CalculationsGroup.Children.Add(
                ProbabilisticPipingCalculationTestFactory.CreateCalculation <ProbabilisticPipingCalculationScenario>(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(AdoptableInitialFailureMechanismResultType.Adopt, cells[initialFailureMechanismResultTypeIndex].Value);
                    Assert.AreEqual(probability, cells[initialFailureMechanismResultProfileProbabilityIndex].FormattedValue);
                    Assert.AreEqual(probability, cells[initialFailureMechanismResultSectionProbabilityIndex].FormattedValue);
                    Assert.AreEqual(FailureMechanismSectionResultFurtherAnalysisType.NotNecessary, cells[furtherAnalysisTypeIndex].Value);
                    Assert.AreEqual(ProbabilityRefinementType.Section, cells[probabilityRefinementTypeIndex].Value);
                    Assert.AreEqual("<afgeleid>", cells[refinedProfileProbabilityIndex].FormattedValue);
                    Assert.AreEqual("-", cells[refinedSectionProbabilityIndex].FormattedValue);
                    Assert.AreEqual("1/100", cells[profileProbabilityIndex].FormattedValue);
                    Assert.AreEqual("1/10", cells[sectionProbabilityIndex].FormattedValue);
                    Assert.AreEqual("10,00", cells[sectionNIndex].FormattedValue);
                    Assert.AreEqual("+I", cells[assemblyGroupIndex].FormattedValue);
                }
        }
        public void ToString_FailureMechanismScenarioConfigurationTypePerSection_ReturnsExpectedName(
            PipingScenarioConfigurationPerFailureMechanismSectionType scenarioConfigurationType, string displayNameSuffix)
        {
            // Setup
            FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
            var pipingFailureMechanism      = new PipingFailureMechanism
            {
                ScenarioConfigurationType = PipingScenarioConfigurationType.PerFailureMechanismSection
            };
            var scenarioConfiguration = new PipingScenarioConfigurationPerFailureMechanismSection(section)
            {
                ScenarioConfigurationType = scenarioConfigurationType
            };

            var viewModel = new PipingScenariosViewFailureMechanismSectionViewModel(section, pipingFailureMechanism, scenarioConfiguration);

            // Call
            var toString = viewModel.ToString();

            // Assert
            Assert.AreEqual($"{section.Name} ({displayNameSuffix})", toString);
        }
Exemplo n.º 4
0
        public void ScenarioConfigurationTypeIsSemiProbabilistic_VariousConfigurations_ReturnsExpectedResult(
            PipingFailureMechanism failureMechanism, PipingScenarioConfigurationPerFailureMechanismSectionType configurationType,
            bool expectedResult)
        {
            // Setup
            FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();

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

            PipingScenarioConfigurationPerFailureMechanismSection scenarioConfigurationPerFailureMechanismSection =
                failureMechanism.ScenarioConfigurationsPerFailureMechanismSection.Single();

            scenarioConfigurationPerFailureMechanismSection.ScenarioConfigurationType = configurationType;

            // Call
            bool isSemiProbabilistic = failureMechanism.ScenarioConfigurationTypeIsSemiProbabilistic(scenarioConfigurationPerFailureMechanismSection);

            // Assert
            Assert.AreEqual(expectedResult, isSemiProbabilistic);
        }