示例#1
0
        public void Finish_ValidCalculationAndRan_SetsOutputAndNotifyObserversOfCalculation()
        {
            // Setup
            var mockRepository = new MockRepository();
            var observer       = mockRepository.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());

            var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>();

            calculatorFactory.Expect(cf => cf.CreateStructuresCalculator <StructuresStabilityPointCalculationInput>(null))
            .IgnoreArguments()
            .Return(new TestStructuresCalculator <StructuresStabilityPointCalculationInput>());
            mockRepository.ReplayAll();

            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);

            DataImportHelper.ImportHydraulicBoundaryDatabase(assessmentSection, validFilePath);

            var failureMechanism = new StabilityPointStructuresFailureMechanism();
            var calculation      = new TestStabilityPointStructuresCalculationScenario
            {
                InputParameters =
                {
                    HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001),
                    InflowModelType           = StabilityPointStructureInflowModelType.LowSill,
                    LoadSchematizationType    = LoadSchematizationType.Linear
                }
            };

            calculation.Attach(observer);

            CalculatableActivity activity = StabilityPointStructuresCalculationActivityFactory.CreateCalculationActivity(calculation,
                                                                                                                         failureMechanism,
                                                                                                                         assessmentSection);

            using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
            {
                activity.Run();
            }

            // Call
            activity.Finish();

            // Assert
            Assert.IsNotNull(calculation.Output);
            mockRepository.VerifyAll();
        }
示例#2
0
        public void GivenCalculationsWithIllustrationPoints_WhenClearIllustrationPointsClickedAndContinued_ThenInquiryAndIllustrationPointsCleared()
        {
            // Given
            var calculationWithIllustrationPoints = new TestStabilityPointStructuresCalculationScenario
            {
                Output = new TestStructuresOutput(new TestGeneralResultFaultTreeIllustrationPoint())
            };

            var calculationWithOutput = new TestStabilityPointStructuresCalculationScenario
            {
                Output = new TestStructuresOutput()
            };

            var failureMechanism = new StabilityPointStructuresFailureMechanism
            {
                CalculationsGroup =
                {
                    Children =
                    {
                        calculationWithIllustrationPoints,
                        calculationWithOutput,
                        new TestStabilityPointStructuresCalculationScenario()
                    }
                }
            };

            var affectedCalculationObserver = mocksRepository.StrictMock <IObserver>();

            affectedCalculationObserver.Expect(o => o.UpdateObserver());
            calculationWithIllustrationPoints.Attach(affectedCalculationObserver);

            var unaffectedCalculationObserver = mocksRepository.StrictMock <IObserver>();

            calculationWithOutput.Attach(unaffectedCalculationObserver);

            IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocksRepository, "invalidFilePath");

            var nodeData    = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);
            var menuBuilder = new CustomItemsOnlyContextMenuBuilder();

            var messageBoxText = "";

            DialogBoxHandler = (name, wnd) =>
            {
                var helper = new MessageBoxTester(wnd);
                messageBoxText = helper.Text;

                helper.ClickOk();
            };

            using (var plugin = new StabilityPointStructuresPlugin())
                using (var treeViewControl = new TreeViewControl())
                {
                    var gui = mocksRepository.Stub <IGui>();
                    gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
                    gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub <IMainWindow>());
                    mocksRepository.ReplayAll();

                    plugin.Gui = gui;
                    TreeNodeInfo info = GetInfo(plugin);

                    using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
                    {
                        // When
                        contextMenu.Items[contextMenuClearIllustrationPointsIndex].PerformClick();

                        // Then
                        Assert.AreEqual("Weet u zeker dat u alle illustratiepunten wilt wissen?", messageBoxText);

                        Assert.IsTrue(calculationWithOutput.HasOutput);
                        Assert.IsFalse(calculationWithIllustrationPoints.Output.HasGeneralResult);
                    }
                }
        }