Beispiel #1
0
        public void ChildNodeObjects_FailureMechanismInAssemblyFalse_ReturnChildDataNodes()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new StabilityPointStructuresFailureMechanism
            {
                InAssembly = false
            };
            var context = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            object[] children = info.ChildNodeObjects(context).ToArray();

            // Assert
            Assert.AreEqual(1, children.Length);

            var comment = (Comment)children[0];

            Assert.AreSame(failureMechanism.NotInAssemblyComments, comment);

            mocks.VerifyAll();
        }
Beispiel #2
0
        public void ContextMenuStrip_WithContext_AddCustomItems()
        {
            // Setup
            using (var plugin = new StabilityPointStructuresPlugin())
                using (var treeView = new TreeViewControl())
                {
                    var assessmentSection = mocksRepository.Stub <IAssessmentSection>();
                    var failureMechanism  = new StabilityPointStructuresFailureMechanism();
                    var context           = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);
                    var menuBuilder       = new CustomItemsOnlyContextMenuBuilder();

                    var gui = mocksRepository.Stub <IGui>();
                    gui.Stub(cmp => cmp.Get(context, treeView)).Return(menuBuilder);
                    gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
                    gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
                    gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub <IMainWindow>());
                    mocksRepository.ReplayAll();

                    plugin.Gui = gui;

                    TreeNodeInfo info = GetInfo(plugin);

                    // Call
                    using (ContextMenuStrip menu = info.ContextMenuStrip(context, assessmentSection, treeView))
                    {
                        // Assert
                        Assert.AreEqual(12, menu.Items.Count);

                        TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndex,
                                                                      "Alles &valideren",
                                                                      "Er zijn geen berekeningen om te valideren.",
                                                                      RiskeerCommonFormsResources.ValidateAllIcon,
                                                                      false);

                        TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndex,
                                                                      "Alles be&rekenen",
                                                                      "Er zijn geen berekeningen om uit te voeren.",
                                                                      RiskeerCommonFormsResources.CalculateAllIcon,
                                                                      false);

                        TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearAllIndex,
                                                                      "&Wis alle uitvoer...",
                                                                      "Er zijn geen berekeningen met uitvoer om te wissen.",
                                                                      RiskeerCommonFormsResources.ClearIcon,
                                                                      false);
                        TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearIllustrationPointsIndex,
                                                                      "Wis alle illustratiepunten...",
                                                                      "Er zijn geen berekeningen met illustratiepunten om te wissen.",
                                                                      RiskeerCommonFormsResources.ClearIllustrationPointsIcon,
                                                                      false);
                    }
                }

            mocksRepository.VerifyAll();
        }
Beispiel #3
0
        public void ContextMenuStrip_FailureMechanismWithCalculationsContainingIllustrationPoints_ContextMenuItemClearIllustrationPointsEnabled()
        {
            // Setup
            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()
                    }
                }
            };

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

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

            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))
                    {
                        // Call
                        ToolStripItem toolStripItem = contextMenu.Items[contextMenuClearIllustrationPointsIndex];

                        // Assert
                        Assert.IsTrue(toolStripItem.Enabled);
                    }
                }
        }
Beispiel #4
0
        public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemCalculateAllAndValidateAllEnabled()
        {
            // Setup
            var failureMechanism = new StabilityPointStructuresFailureMechanism();

            failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation <StabilityPointStructuresInput>());

            string validFilePath             = Path.Combine(testDataPath, "complete.sqlite");
            var    hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
            {
                FilePath = validFilePath,
                Version  = "1.0"
            };

            HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase);

            var assessmentSection = mocksRepository.Stub <IAssessmentSection>();

            assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase);

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

            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();

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

                    // Call
                    using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl))
                    {
                        // Assert
                        TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndex,
                                                                      "Alles be&rekenen",
                                                                      "Voer alle berekeningen binnen dit faalmechanisme uit.",
                                                                      RiskeerCommonFormsResources.CalculateAllIcon);

                        TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndex,
                                                                      "Alles &valideren",
                                                                      "Valideer alle berekeningen binnen dit faalmechanisme.",
                                                                      RiskeerCommonFormsResources.ValidateAllIcon);
                    }
                }
        }
Beispiel #5
0
        public void ChildNodeObjects_FailureMechanismInAssemblyTrue_ReturnChildDataNodes()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new StabilityPointStructuresFailureMechanism();
            var context           = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            object[] children = info.ChildNodeObjects(context).ToArray();

            // Assert
            Assert.AreEqual(2, children.Length);
            var inputsFolder = (CategoryTreeFolder)children[0];

            Assert.AreEqual("Invoer", inputsFolder.Name);
            Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category);

            Assert.AreEqual(2, inputsFolder.Contents.Count());
            var failureMechanismSectionsContext = (FailureMechanismSectionsContext)inputsFolder.Contents.ElementAt(0);

            Assert.AreSame(failureMechanism, failureMechanismSectionsContext.WrappedData);
            Assert.AreSame(assessmentSection, failureMechanismSectionsContext.AssessmentSection);

            var inAssemblyInputComments = (Comment)inputsFolder.Contents.ElementAt(1);

            Assert.AreSame(failureMechanism.InAssemblyInputComments, inAssemblyInputComments);

            var outputsFolder = (CategoryTreeFolder)children[1];

            Assert.AreEqual("Oordeel", outputsFolder.Name);
            Assert.AreEqual(TreeFolderCategory.Output, outputsFolder.Category);

            Assert.AreEqual(3, outputsFolder.Contents.Count());

            var scenariosContext = (StabilityPointStructuresScenariosContext)outputsFolder.Contents.ElementAt(0);

            Assert.AreSame(failureMechanism, scenariosContext.ParentFailureMechanism);
            Assert.AreSame(failureMechanism.CalculationsGroup, scenariosContext.WrappedData);

            var failureMechanismResultsContext = (StabilityPointStructuresFailureMechanismSectionResultContext)outputsFolder.Contents.ElementAt(1);

            Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism);
            Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.WrappedData);
            Assert.AreSame(assessmentSection, failureMechanismResultsContext.AssessmentSection);

            var inAssemblyOutputComments = (Comment)outputsFolder.Contents.ElementAt(2);

            Assert.AreSame(failureMechanism.InAssemblyOutputComments, inAssemblyOutputComments);
        }
        public void CreateInstance_WithContext_ReturnStabilityPointStructuresFailureMechanismView()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new StabilityPointStructuresFailureMechanism();

            var context = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            var view = (StabilityPointStructuresFailureMechanismView)info.CreateInstance(context);

            // Assert
            Assert.AreSame(failureMechanism, view.FailureMechanism);
            Assert.AreSame(assessmentSection, view.AssessmentSection);
        }
        public void GetViewName_WithContext_ReturnsNameOfFailureMechanism()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new StabilityPointStructuresFailureMechanism();
            var context          = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            string viewName = info.GetViewName(null, context);

            // Assert
            Assert.AreEqual(failureMechanism.Name, viewName);
        }
Beispiel #8
0
        public void Text_WithContext_ReturnsName()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var context = new StabilityPointStructuresFailureMechanismContext(new StabilityPointStructuresFailureMechanism(), assessmentSection);

            // Call
            string text = info.Text(context);

            // Assert
            Assert.AreEqual("Sterkte en stabiliteit puntconstructies", text);
            mocks.VerifyAll();
        }
Beispiel #9
0
        public void CloseForData_ViewCorrespondingToRemovedCalculationsContext_ReturnsTrue()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new StabilityPointStructuresFailureMechanism();

            using (var view = new StabilityPointStructuresCalculationsView(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection))
            {
                var context = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

                // Call
                bool closeForData = info.CloseForData(view, context);

                // Assert
                Assert.IsTrue(closeForData);
            }
        }
Beispiel #10
0
        public void ContextMenuStrip_WithContext_CallsContextMenuBuilderMethods()
        {
            // Setup
            var failureMechanism  = new StabilityPointStructuresFailureMechanism();
            var assessmentSection = mocksRepository.Stub <IAssessmentSection>();
            var context           = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

            var menuBuilder = mocksRepository.StrictMock <IContextMenuBuilder>();

            using (mocksRepository.Ordered())
            {
                menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.Build()).Return(null);
            }

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

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

                    // Call
                    info.ContextMenuStrip(context, null, treeViewControl);
                }

            // Assert
            mocksRepository.VerifyAll();
        }
Beispiel #11
0
        public void ContextMenuStrip_HydraulicBoundaryDatabaseLinkedToInvalidFile_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet()
        {
            // Setup
            var failureMechanism = new StabilityPointStructuresFailureMechanism();

            failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation <StabilityPointStructuresInput>());

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

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

            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();

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

                    // Call
                    using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
                    {
                        // Assert
                        ToolStripItem calculateAllContextMenuItem = contextMenu.Items[contextMenuCalculateAllIndex];

                        Assert.AreEqual("Alles be&rekenen", calculateAllContextMenuItem.Text);
                        StringAssert.Contains("Herstellen van de verbinding met de hydraulische belastingendatabase is mislukt.", calculateAllContextMenuItem.ToolTipText);
                        TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.CalculateAllIcon, calculateAllContextMenuItem.Image);
                        Assert.IsFalse(calculateAllContextMenuItem.Enabled);

                        ToolStripItem validateAllContextMenuItem = contextMenu.Items[contextMenuValidateAllIndex];

                        Assert.AreEqual("Alles &valideren", validateAllContextMenuItem.Text);
                        StringAssert.Contains("Herstellen van de verbinding met de hydraulische belastingendatabase is mislukt.", validateAllContextMenuItem.ToolTipText);
                        TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.ValidateAllIcon, validateAllContextMenuItem.Image);
                        Assert.IsFalse(validateAllContextMenuItem.Enabled);
                    }
                }
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new StabilityPointStructuresFailureMechanism();

            // Call
            var context = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

            // Assert
            Assert.IsInstanceOf <FailureMechanismContext <StabilityPointStructuresFailureMechanism> >(context);
            Assert.AreSame(assessmentSection, context.Parent);
            Assert.AreSame(failureMechanism, context.WrappedData);
            mocks.VerifyAll();
        }
Beispiel #13
0
        public void ChildNodeObjects_WithContext_ReturnChildDataNodes()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new StabilityPointStructuresFailureMechanism();
            var context           = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

            using (var plugin = new StabilityPointStructuresPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                object[] children = info.ChildNodeObjects(context).ToArray();

                // Assert
                Assert.AreEqual(2, children.Length);

                var inputsFolder = (CategoryTreeFolder)children[0];
                Assert.AreEqual("Invoer", inputsFolder.Name);
                Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category);

                Assert.AreEqual(3, inputsFolder.Contents.Count());
                var profilesContext = (ForeshoreProfilesContext)inputsFolder.Contents.ElementAt(0);
                Assert.AreSame(failureMechanism.ForeshoreProfiles, profilesContext.WrappedData);
                Assert.AreSame(failureMechanism, profilesContext.ParentFailureMechanism);
                Assert.AreSame(assessmentSection, profilesContext.ParentAssessmentSection);

                var stabilityPointStructuresContext = (StabilityPointStructuresContext)inputsFolder.Contents.ElementAt(1);
                Assert.AreSame(failureMechanism.StabilityPointStructures, stabilityPointStructuresContext.WrappedData);
                Assert.AreSame(failureMechanism, stabilityPointStructuresContext.FailureMechanism);
                Assert.AreSame(assessmentSection, stabilityPointStructuresContext.AssessmentSection);

                var calculationsInputComments = (Comment)inputsFolder.Contents.ElementAt(2);
                Assert.AreSame(failureMechanism.CalculationsInputComments, calculationsInputComments);

                var calculationsFolder = (StabilityPointStructuresCalculationGroupContext)children[1];
                Assert.AreSame(failureMechanism.CalculationsGroup, calculationsFolder.WrappedData);
                Assert.IsNull(calculationsFolder.Parent);
                Assert.AreSame(failureMechanism, calculationsFolder.FailureMechanism);
            }

            mocksRepository.VerifyAll();
        }
Beispiel #14
0
        public void CreateInstance_WithContext_NewPropertiesWithFailureMechanismAsData()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new StabilityPointStructuresFailureMechanism();
            var context          = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            IObjectProperties objectProperties = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <StabilityPointStructuresFailureMechanismProperties>(objectProperties);
            Assert.AreSame(failureMechanism, objectProperties.Data);

            mocks.VerifyAll();
        }
Beispiel #15
0
        public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet()
        {
            // Setup
            var failureMechanism = new StabilityPointStructuresFailureMechanism();

            failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation <StabilityPointStructuresInput>());

            IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocksRepository);

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

            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();

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

                    // Call
                    using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
                    {
                        // Assert
                        TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateAllIndex,
                                                                      "Alles be&rekenen",
                                                                      "Er is geen hydraulische belastingendatabase geïmporteerd.",
                                                                      RiskeerCommonFormsResources.CalculateAllIcon,
                                                                      false);

                        TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuValidateAllIndex,
                                                                      "Alles &valideren",
                                                                      "Er is geen hydraulische belastingendatabase geïmporteerd.",
                                                                      RiskeerCommonFormsResources.ValidateAllIcon,
                                                                      false);
                    }
                }
        }
Beispiel #16
0
        public void AdditionalDataCheck_Always_ReturnTrueOnlyIfFailureMechanismInAssembly(bool inAssembly)
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new StabilityPointStructuresFailureMechanism
            {
                InAssembly = inAssembly
            };

            var context = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            bool result = info.AdditionalDataCheck(context);

            // Assert
            Assert.AreEqual(inAssembly, result);
            mocks.VerifyAll();
        }
Beispiel #17
0
        public void Text_WithContext_ReturnsName()
        {
            // Setup
            var assessmentSection = mocksRepository.Stub <IAssessmentSection>();

            mocksRepository.ReplayAll();

            var failureMechanism = new StabilityPointStructuresFailureMechanism();
            var context          = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

            using (var plugin = new StabilityPointStructuresPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                string text = info.Text(context);

                // Assert
                Assert.AreEqual(failureMechanism.Name, text);
            }
        }
        public void CloseForData_ViewCorrespondingToRemovedFailureMechanismContext_ReturnTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new StabilityPointStructuresFailureMechanism();
            var context          = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

            using (var view = new StabilityPointStructuresScenariosView(failureMechanism.CalculationsGroup, failureMechanism))
            {
                // Call
                bool closeForData = info.CloseForData(view, context);

                // Assert
                Assert.IsTrue(closeForData);
            }

            mocks.VerifyAll();
        }
Beispiel #19
0
        public void ContextMenuStrip_FailureMechanismInAssemblyFalse_CallsContextMenuBuilderMethods()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            using (var treeViewControl = new TreeViewControl())
            {
                var failureMechanism = new StabilityPointStructuresFailureMechanism
                {
                    InAssembly = false
                };
                var context = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

                var menuBuilder = mocks.StrictMock <IContextMenuBuilder>();
                using (mocks.Ordered())
                {
                    menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
                    menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
                    menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder);
                    menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder);
                    menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
                    menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder);
                    menuBuilder.Expect(mb => mb.Build()).Return(null);
                }

                var gui = mocks.Stub <IGui>();
                gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
                mocks.ReplayAll();

                plugin.Gui = gui;

                // Call
                info.ContextMenuStrip(context, null, treeViewControl);
            }

            // Assert
            mocks.VerifyAll();
        }
Beispiel #20
0
        public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanismContext_ReturnsFalse()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new StabilityPointStructuresFailureMechanism();
            var context          = new StabilityPointStructuresFailureMechanismContext(new StabilityPointStructuresFailureMechanism(), assessmentSection);

            using (var view = new StructuresFailureMechanismResultView <StabilityPointStructuresFailureMechanism, StabilityPointStructuresInput>(
                       failureMechanism.SectionResults, failureMechanism, assessmentSection,
                       (fm, ass) => new FailureMechanismAssemblyResultWrapper(double.NaN, AssemblyMethod.Manual)))
            {
                // Call
                bool closeForData = info.CloseForData(view, context);

                // Assert
                Assert.IsFalse(closeForData);
            }

            mocks.VerifyAll();
        }
Beispiel #21
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);
                    }
                }
        }
Beispiel #22
0
        public void ContextMenuStrip_ClickOnValidateAllItem_ValidateAllChildCalculations()
        {
            // Setup
            var failureMechanism = new StabilityPointStructuresFailureMechanism();

            failureMechanism.CalculationsGroup.Children.Add(new TestStabilityPointStructuresCalculationScenario
            {
                Name            = "A",
                InputParameters =
                {
                    HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(),
                    InflowModelType           = StabilityPointStructureInflowModelType.LowSill,
                    LoadSchematizationType    = LoadSchematizationType.Linear
                }
            });
            failureMechanism.CalculationsGroup.Children.Add(new TestStabilityPointStructuresCalculationScenario
            {
                Name            = "B",
                InputParameters =
                {
                    HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(),
                    InflowModelType           = StabilityPointStructureInflowModelType.LowSill,
                    LoadSchematizationType    = LoadSchematizationType.Linear
                }
            });

            string validFilePath             = Path.Combine(testDataPath, "complete.sqlite");
            var    hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
            {
                FilePath = validFilePath
            };

            HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase);

            var assessmentSection = mocksRepository.Stub <IAssessmentSection>();

            assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase);

            var context = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

            using (var plugin = new StabilityPointStructuresPlugin())
                using (var treeViewControl = new TreeViewControl())
                {
                    var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
                    var gui         = mocksRepository.Stub <IGui>();
                    gui.Stub(g => g.Get(context, 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(context, null, treeViewControl))
                    {
                        // Call
                        void Call() => contextMenu.Items[contextMenuValidateAllIndex].PerformClick();

                        // Assert
                        TestHelper.AssertLogMessages(Call, messages =>
                        {
                            string[] messageList = messages.ToArray();

                            Assert.AreEqual(4, messageList.Length);
                            CalculationServiceTestHelper.AssertValidationStartMessage(messageList[0]);
                            CalculationServiceTestHelper.AssertValidationEndMessage(messageList[1]);
                            CalculationServiceTestHelper.AssertValidationStartMessage(messageList[2]);
                            CalculationServiceTestHelper.AssertValidationEndMessage(messageList[3]);
                        });
                    }
                }
        }
Beispiel #23
0
        public void ContextMenuStrip_ClickOnCalculateAllItem_ScheduleAllChildCalculations()
        {
            // Setup
            var menuBuilder = new CustomItemsOnlyContextMenuBuilder();

            var failureMechanism = new StabilityPointStructuresFailureMechanism();

            failureMechanism.CalculationsGroup.Children.Add(new TestStabilityPointStructuresCalculationScenario
            {
                Name            = "A",
                InputParameters =
                {
                    HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(),
                    Structure              = new TestStabilityPointStructure(),
                    InflowModelType        = StabilityPointStructureInflowModelType.LowSill,
                    LoadSchematizationType = LoadSchematizationType.Linear
                }
            });
            failureMechanism.CalculationsGroup.Children.Add(new TestStabilityPointStructuresCalculationScenario
            {
                Name            = "B",
                InputParameters =
                {
                    HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(),
                    Structure              = new TestStabilityPointStructure(),
                    InflowModelType        = StabilityPointStructureInflowModelType.LowSill,
                    LoadSchematizationType = LoadSchematizationType.Linear
                }
            });

            var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
            {
                FilePath = Path.Combine(testDataPath, "complete.sqlite")
            };

            HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase);

            var assessmentSection = mocksRepository.Stub <IAssessmentSection>();

            assessmentSection.Stub(a => a.Id).Return(string.Empty);
            assessmentSection.Stub(a => a.FailureMechanismContribution).Return(FailureMechanismContributionTestFactory.CreateFailureMechanismContribution());
            assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase);

            var context = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

            using (var plugin = new StabilityPointStructuresPlugin())
                using (var treeViewControl = new TreeViewControl())
                {
                    IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mocksRepository);

                    var gui = mocksRepository.Stub <IGui>();
                    gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder);
                    gui.Stub(g => g.MainWindow).Return(mainWindow);

                    int nrOfCalculators   = failureMechanism.Calculations.Count();
                    var calculatorFactory = mocksRepository.Stub <IHydraRingCalculatorFactory>();
                    calculatorFactory.Expect(cf => cf.CreateStructuresCalculator <StructuresStabilityPointCalculationInput>(
                                                 Arg <HydraRingCalculationSettings> .Is.NotNull))
                    .WhenCalled(invocation =>
                    {
                        HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings(
                            HydraulicBoundaryCalculationSettingsFactory.CreateSettings(hydraulicBoundaryDatabase),
                            (HydraRingCalculationSettings)invocation.Arguments[0]);
                    })
                    .Return(new TestStructuresCalculator <StructuresStabilityPointCalculationInput>())
                    .Repeat
                    .Times(nrOfCalculators);
                    mocksRepository.ReplayAll();

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

                    DialogBoxHandler = (name, wnd) =>
                    {
                        // Expect an activity dialog which is automatically closed
                    };

                    using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl))
                        using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
                        {
                            // Call
                            TestHelper.AssertLogMessages(() => contextMenu.Items[contextMenuCalculateAllIndex].PerformClick(), messages =>
                            {
                                List <string> messageList = messages.ToList();

                                // Assert
                                Assert.AreEqual(14, messageList.Count);
                                Assert.AreEqual("Uitvoeren van berekening 'A' is gestart.", messageList[0]);
                                CalculationServiceTestHelper.AssertValidationStartMessage(messageList[1]);
                                CalculationServiceTestHelper.AssertValidationEndMessage(messageList[2]);
                                CalculationServiceTestHelper.AssertCalculationStartMessage(messageList[3]);
                                StringAssert.StartsWith("Puntconstructies berekening is uitgevoerd op de tijdelijke locatie", messageList[4]);
                                CalculationServiceTestHelper.AssertCalculationEndMessage(messageList[5]);
                                Assert.AreEqual("Uitvoeren van berekening 'A' is gelukt.", messageList[6]);

                                Assert.AreEqual("Uitvoeren van berekening 'B' is gestart.", messageList[7]);
                                CalculationServiceTestHelper.AssertValidationStartMessage(messageList[8]);
                                CalculationServiceTestHelper.AssertValidationEndMessage(messageList[9]);
                                CalculationServiceTestHelper.AssertCalculationStartMessage(messageList[10]);
                                StringAssert.StartsWith("Puntconstructies berekening is uitgevoerd op de tijdelijke locatie", messageList[11]);
                                CalculationServiceTestHelper.AssertCalculationEndMessage(messageList[12]);
                                Assert.AreEqual("Uitvoeren van berekening 'B' is gelukt.", messageList[13]);
                            });
                        }
                }
        }