コード例 #1
0
        /// <summary>
        /// Creates a <see cref="UpdateInfo"/> object for a <see cref="PipingFailureMechanismSectionsContext"/>.
        /// </summary>
        /// <param name="inquiryHelper">Object responsible for inquiring required data.</param>
        /// <returns>An <see cref="UpdateInfo"/> object.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="inquiryHelper"/>
        /// is <c>null</c>.</exception>
        public static UpdateInfo <PipingFailureMechanismSectionsContext> CreateFailureMechanismSectionsUpdateInfo(
            IInquiryHelper inquiryHelper)
        {
            if (inquiryHelper == null)
            {
                throw new ArgumentNullException(nameof(inquiryHelper));
            }

            return(new UpdateInfo <PipingFailureMechanismSectionsContext>
            {
                Name = RiskeerCommonFormsResources.FailureMechanismSections_DisplayName,
                Category = RiskeerCommonFormsResources.Riskeer_Category,
                Image = RiskeerCommonFormsResources.SectionsIcon,
                FileFilterGenerator = new FileFilterGenerator(RiskeerCommonIOResources.Shape_file_filter_Extension,
                                                              RiskeerCommonIOResources.Shape_file_filter_Description),
                IsEnabled = context => context.WrappedData.FailureMechanismSectionSourcePath != null,
                CurrentPath = context => context.WrappedData.FailureMechanismSectionSourcePath,
                CreateFileImporter = (context, filePath) => new FailureMechanismSectionsImporter(
                    context.WrappedData,
                    context.AssessmentSection.ReferenceLine,
                    filePath,
                    new PipingFailureMechanismSectionUpdateStrategy((PipingFailureMechanism)context.WrappedData,
                                                                    new AdoptableWithProfileProbabilityFailureMechanismSectionResultUpdateStrategy()),
                    new UpdateMessageProvider()),
                VerifyUpdates = context =>
                {
                    var changeHandler = new PipingFailureMechanismCalculationChangeHandler(
                        (PipingFailureMechanism)context.WrappedData,
                        Resources.PipingUpdateInfoFactory_CreateFailureMechanismSectionsUpdateInfo_When_updating_sections_probabilistic_calculation_output_will_be_cleared_confirm,
                        inquiryHelper);
                    return !changeHandler.RequireConfirmation() || changeHandler.InquireConfirmation();
                }
            });
        }
コード例 #2
0
        public void RequireConfirmation_NoProbabilisticCalculations_ReturnsFalse()
        {
            // Setup
            var mocks         = new MockRepository();
            var inquiryHelper = mocks.Stub <IInquiryHelper>();

            mocks.ReplayAll();

            var failureMechanism = new PipingFailureMechanism();

            failureMechanism.CalculationsGroup.Children.AddRange(new IPipingCalculationScenario <PipingInput>[]
            {
                new SemiProbabilisticPipingCalculationScenario(),
                new TestPipingCalculationScenario()
            });

            var changeHandler = new PipingFailureMechanismCalculationChangeHandler(failureMechanism, string.Empty, inquiryHelper);

            // Call
            bool requireConfirmation = changeHandler.RequireConfirmation();

            // Assert
            Assert.IsFalse(requireConfirmation);
            mocks.VerifyAll();
        }
コード例 #3
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocks         = new MockRepository();
            var inquiryHelper = mocks.Stub <IInquiryHelper>();

            mocks.ReplayAll();

            // Call
            var changeHandler = new PipingFailureMechanismCalculationChangeHandler(new PipingFailureMechanism(), string.Empty, inquiryHelper);

            // Assert
            Assert.IsInstanceOf <FailureMechanismCalculationChangeHandler>(changeHandler);
            mocks.VerifyAll();
        }
コード例 #4
0
        public void RequireConfirmation_ProbabilisticCalculationsWithOutput_ReturnsTrue()
        {
            // Setup
            var mocks         = new MockRepository();
            var inquiryHelper = mocks.Stub <IInquiryHelper>();

            mocks.ReplayAll();

            var failureMechanism = new PipingFailureMechanism();

            failureMechanism.CalculationsGroup.Children.Add(new ProbabilisticPipingCalculationScenario
            {
                Output = PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithIllustrationPoints()
            });

            var changeHandler = new PipingFailureMechanismCalculationChangeHandler(failureMechanism, string.Empty, inquiryHelper);

            // Call
            bool requireConfirmation = changeHandler.RequireConfirmation();

            // Assert
            Assert.IsTrue(requireConfirmation);
            mocks.VerifyAll();
        }