Ejemplo n.º 1
0
 private void Calculate(ClosingStructuresCalculationScenarioContext context)
 {
     ActivityProgressDialogRunner.Run(Gui.MainWindow,
                                      ClosingStructuresCalculationActivityFactory.CreateCalculationActivity(context.WrappedData,
                                                                                                            context.FailureMechanism,
                                                                                                            context.AssessmentSection));
 }
Ejemplo n.º 2
0
        private StrictContextMenuItem CreateUpdateStructureItem(ClosingStructuresCalculationScenarioContext context)
        {
            var    contextMenuEnabled = true;
            string toolTipMessage     = RiskeerCommonFormsResources.Update_Calculation_with_Structure_ToolTip;

            if (context.WrappedData.InputParameters.Structure == null)
            {
                contextMenuEnabled = false;
                toolTipMessage     = RiskeerCommonFormsResources.Structure_must_be_selected_ToolTip;
            }
            else if (context.WrappedData.InputParameters.IsStructureInputSynchronized)
            {
                contextMenuEnabled = false;
                toolTipMessage     = RiskeerCommonFormsResources.CalculationItem_No_changes_to_update_ToolTip;
            }

            return(new StrictContextMenuItem(
                       RiskeerCommonFormsResources.Update_Structure_data,
                       toolTipMessage,
                       RiskeerCommonFormsResources.UpdateItemIcon,
                       (o, args) => UpdateStructureDependentDataOfCalculation(context.WrappedData))
            {
                Enabled = contextMenuEnabled
            });
        }
Ejemplo n.º 3
0
 private static void CalculationContextOnNodeRemoved(ClosingStructuresCalculationScenarioContext context, object parentData)
 {
     if (parentData is ClosingStructuresCalculationGroupContext calculationGroupContext)
     {
         calculationGroupContext.WrappedData.Children.Remove(context.WrappedData);
         calculationGroupContext.NotifyObservers();
     }
 }
Ejemplo n.º 4
0
        private static object[] CalculationContextChildNodeObjects(ClosingStructuresCalculationScenarioContext context)
        {
            StructuresCalculation <ClosingStructuresInput> calculation = context.WrappedData;

            return(new object[]
            {
                calculation.Comments,
                new ClosingStructuresInputContext(calculation.InputParameters,
                                                  calculation,
                                                  context.FailureMechanism,
                                                  context.AssessmentSection),
                new StructuresOutputContext(calculation)
            });
        }
Ejemplo n.º 5
0
        public void CreateFileExporter_Always_ReturnFileExporter()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var context = new ClosingStructuresCalculationScenarioContext(new TestClosingStructuresCalculationScenario(),
                                                                          new CalculationGroup(),
                                                                          new ClosingStructuresFailureMechanism(),
                                                                          assessmentSection);

            // Call
            IFileExporter fileExporter = info.CreateFileExporter(context, "test");

            // Assert
            Assert.IsInstanceOf <ClosingStructuresCalculationConfigurationExporter>(fileExporter);
        }
Ejemplo n.º 6
0
        public void IsEnabled_Always_ReturnTrue()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var context = new ClosingStructuresCalculationScenarioContext(new TestClosingStructuresCalculationScenario(),
                                                                          new CalculationGroup(),
                                                                          new ClosingStructuresFailureMechanism(),
                                                                          assessmentSection);

            // Call
            bool isEnabled = info.IsEnabled(context);

            // Assert
            Assert.IsTrue(isEnabled);
        }
Ejemplo n.º 7
0
        public void Equals_ToDerivedObject_ReturnsFalse()
        {
            // Setup
            var mocksRepository   = new MockRepository();
            var assessmentSection = mocksRepository.Stub <IAssessmentSection>();

            mocksRepository.ReplayAll();

            var calculation      = new StructuresCalculationScenario <ClosingStructuresInput>();
            var failureMechanism = new ClosingStructuresFailureMechanism();
            var parent           = new CalculationGroup();
            var context          = new ClosingStructuresCalculationScenarioContext(calculation, parent, failureMechanism, assessmentSection);
            var derivedContext   = new DerivedClosingStructuresCalculationScenarioContext(calculation, parent, failureMechanism, assessmentSection);

            // Call
            bool isEqual = context.Equals(derivedContext);

            // Assert
            Assert.IsFalse(isEqual);
            mocksRepository.VerifyAll();
        }
Ejemplo n.º 8
0
        private ContextMenuStrip CalculationContextContextMenuStrip(ClosingStructuresCalculationScenarioContext context,
                                                                    object parentData,
                                                                    TreeViewControl treeViewControl)
        {
            StructuresCalculation <ClosingStructuresInput> calculation = context.WrappedData;
            var changeHandler = new ClearIllustrationPointsOfStructuresCalculationHandler(GetInquiryHelper(), calculation);

            var builder = new RiskeerContextMenuBuilder(Gui.Get(context, treeViewControl));

            return(builder.AddExportItem()
                   .AddSeparator()
                   .AddDuplicateCalculationItem(calculation, context)
                   .AddSeparator()
                   .AddRenameItem()
                   .AddUpdateForeshoreProfileOfCalculationItem(calculation,
                                                               GetInquiryHelper(),
                                                               SynchronizeCalculationWithForeshoreProfileHelper.UpdateForeshoreProfileDerivedCalculationInput)
                   .AddCustomItem(CreateUpdateStructureItem(context))
                   .AddSeparator()
                   .AddValidateCalculationItem(
                       context,
                       Validate,
                       EnableValidateAndCalculateMenuItemForCalculation)
                   .AddPerformCalculationItem <StructuresCalculationScenario <ClosingStructuresInput>, ClosingStructuresCalculationScenarioContext>(
                       context,
                       Calculate,
                       EnableValidateAndCalculateMenuItemForCalculation)
                   .AddSeparator()
                   .AddClearCalculationOutputItem(calculation)
                   .AddClearIllustrationPointsOfCalculationItem(() => IllustrationPointsHelper.HasIllustrationPoints(calculation), changeHandler)
                   .AddDeleteItem()
                   .AddSeparator()
                   .AddCollapseAllItem()
                   .AddExpandAllItem()
                   .AddSeparator()
                   .AddPropertiesItem()
                   .Build());
        }
Ejemplo n.º 9
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocksRepository   = new MockRepository();
            var assessmentSection = mocksRepository.Stub <IAssessmentSection>();

            mocksRepository.ReplayAll();

            var calculation      = new StructuresCalculationScenario <ClosingStructuresInput>();
            var failureMechanism = new ClosingStructuresFailureMechanism();
            var parent           = new CalculationGroup();

            // Call
            var context = new ClosingStructuresCalculationScenarioContext(calculation, parent, failureMechanism, assessmentSection);

            // Assert
            Assert.IsInstanceOf <StructuresCalculationScenarioContext <ClosingStructuresInput, ClosingStructuresFailureMechanism> >(context);
            Assert.AreSame(calculation, context.WrappedData);
            Assert.AreSame(parent, context.Parent);
            Assert.AreSame(failureMechanism, context.FailureMechanism);
            Assert.AreSame(assessmentSection, context.AssessmentSection);
            mocksRepository.VerifyAll();
        }
Ejemplo n.º 10
0
 private static void Validate(ClosingStructuresCalculationScenarioContext context)
 {
     ClosingStructuresCalculationService.Validate(context.WrappedData, context.AssessmentSection);
 }
Ejemplo n.º 11
0
 private static string EnableValidateAndCalculateMenuItemForCalculation(ClosingStructuresCalculationScenarioContext context)
 {
     return(EnableValidateAndCalculateMenuItem(context.AssessmentSection));
 }