public void ChildNodeObjects_FailureMechanismInAssemblyFalse_ReturnChildDataNodes() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism { InAssembly = false }; var context = new ClosingStructuresFailureMechanismContext(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(); }
public void ContextMenuStrip_FailureMechanismWithCalculationsContainingIllustrationPoints_ContextMenuItemClearIllustrationPointsEnabled() { // Setup var calculationWithIllustrationPoints = new TestClosingStructuresCalculationScenario { Output = new TestStructuresOutput(new TestGeneralResultFaultTreeIllustrationPoint()) }; var calculationWithOutput = new TestClosingStructuresCalculationScenario { Output = new TestStructuresOutput() }; var failureMechanism = new ClosingStructuresFailureMechanism { CalculationsGroup = { Children = { calculationWithIllustrationPoints, calculationWithOutput, new TestClosingStructuresCalculationScenario() } } }; IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocksRepository, "invalidFilePath"); var nodeData = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); 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; using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Call ToolStripItem toolStripItem = contextMenu.Items[contextMenuClearIllustrationPointsIndex]; // Assert Assert.IsTrue(toolStripItem.Enabled); } } }
public void ChildNodeObjects_FailureMechanismInAssemblyTrue_ReturnChildDataNodes() { // Setup var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new ClosingStructuresFailureMechanism(); var context = new ClosingStructuresFailureMechanismContext(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 = (ClosingStructuresScenariosContext)outputsFolder.Contents.ElementAt(0); Assert.AreSame(failureMechanism, scenariosContext.ParentFailureMechanism); Assert.AreSame(failureMechanism.CalculationsGroup, scenariosContext.WrappedData); var failureMechanismResultsContext = (ClosingStructuresFailureMechanismSectionResultContext)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 ContextMenuStrip_WithContext_AddCustomItems() { // Setup using (var treeView = new TreeViewControl()) { var assessmentSection = mocksRepository.Stub <IAssessmentSection>(); var failureMechanism = new ClosingStructuresFailureMechanism(); var context = new ClosingStructuresFailureMechanismContext(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; // 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); } } }
public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemCalculateAllAndValidateAllEnabled() { // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation <ClosingStructuresInput>()); 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 ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); 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; // 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); } } }
public void CreateInstance_WithContext_ReturnClosingStructuresFailureMechanismView() { // Setup var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new ClosingStructuresFailureMechanism(); var context = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call var view = (ClosingStructuresFailureMechanismView)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 ClosingStructuresFailureMechanism(); var context = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call string viewName = info.GetViewName(null, context); // Assert Assert.AreEqual(failureMechanism.Name, viewName); }
public void Text_WithContext_ReturnsName() { // Setup var assessmentSection = mocksRepository.Stub <IAssessmentSection>(); mocksRepository.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); var context = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call string text = info.Text(context); // Assert Assert.AreEqual(failureMechanism.Name, text); }
public void Text_WithContext_ReturnsName() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var context = new ClosingStructuresFailureMechanismContext(new ClosingStructuresFailureMechanism(), assessmentSection); // Call string text = info.Text(context); // Assert Assert.AreEqual("Betrouwbaarheid sluiting kunstwerk", text); mocks.VerifyAll(); }
public void CloseForData_ViewCorrespondingToRemovedCalculationsContext_ReturnsTrue() { // Setup var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new ClosingStructuresFailureMechanism(); using (var view = new ClosingStructuresCalculationsView(failureMechanism.CalculationsGroup, new ClosingStructuresFailureMechanism(), assessmentSection)) { var context = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call bool closeForData = info.CloseForData(view, context); // Assert Assert.IsTrue(closeForData); } }
public void Constructor_ExpectedValues() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); // Call var context = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Assert Assert.IsInstanceOf <FailureMechanismContext <ClosingStructuresFailureMechanism> >(context); Assert.AreSame(assessmentSection, context.Parent); Assert.AreSame(failureMechanism, context.WrappedData); mocks.VerifyAll(); }
public void ContextMenuStrip_WithContext_CallsContextMenuBuilderMethods() { // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); var assessmentSection = mocksRepository.Stub <IAssessmentSection>(); var context = new ClosingStructuresFailureMechanismContext(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 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; // Call info.ContextMenuStrip(context, null, treeViewControl); } // Assert // Assert is done in TearDown }
public void CreateInstance_WithContext_NewPropertiesWithFailureMechanismAsData() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); var context = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call IObjectProperties objectProperties = info.CreateInstance(context); // Assert Assert.IsInstanceOf <ClosingStructuresFailureMechanismProperties>(objectProperties); Assert.AreSame(failureMechanism, objectProperties.Data); mocks.VerifyAll(); }
public void ContextMenuStrip_HydraulicBoundaryDatabaseLinkedToInvalidFile_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet() { // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation <ClosingStructuresInput>()); IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocksRepository, "invalidFilePath"); var nodeData = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); 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; // 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 ChildNodeObjects_WithContext_ReturnChildDataNodes() { // Setup var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new ClosingStructuresFailureMechanism(); var context = new ClosingStructuresFailureMechanismContext(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(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 closingStructuresContext = (ClosingStructuresContext)inputsFolder.Contents.ElementAt(1); Assert.AreSame(failureMechanism.ClosingStructures, closingStructuresContext.WrappedData); Assert.AreSame(failureMechanism, closingStructuresContext.FailureMechanism); Assert.AreSame(assessmentSection, closingStructuresContext.AssessmentSection); var calculationsInputComments = (Comment)inputsFolder.Contents.ElementAt(2); Assert.AreSame(failureMechanism.CalculationsInputComments, calculationsInputComments); var calculationsFolder = (ClosingStructuresCalculationGroupContext)children[1]; Assert.AreEqual(failureMechanism.CalculationsGroup, calculationsFolder.WrappedData); Assert.IsNull(calculationsFolder.Parent); Assert.AreEqual(failureMechanism, calculationsFolder.FailureMechanism); }
public void AdditionalDataCheck_Always_ReturnTrueOnlyIfFailureMechanismInAssembly(bool inAssembly) { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism { InAssembly = inAssembly }; var context = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call bool result = info.AdditionalDataCheck(context); // Assert Assert.AreEqual(inAssembly, result); mocks.VerifyAll(); }
public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet() { // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation <ClosingStructuresInput>()); IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocksRepository); var nodeData = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); 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; // 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); } } }
public void ContextMenuStrip_FailureMechanismInAssemblyFalse_CallsContextMenuBuilderMethods() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); using (var treeViewControl = new TreeViewControl()) { var failureMechanism = new ClosingStructuresFailureMechanism { InAssembly = false }; var context = new ClosingStructuresFailureMechanismContext(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(); }
public void CloseForData_ViewCorrespondingToRemovedFailureMechanismContext_ReturnTrue() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); var context = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); using (var view = new ClosingStructuresScenariosView(failureMechanism.CalculationsGroup, failureMechanism)) { // Call bool closeForData = info.CloseForData(view, context); // Assert Assert.IsTrue(closeForData); } mocks.VerifyAll(); }
public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanismContext_ReturnsFalse() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var context = new ClosingStructuresFailureMechanismContext(new ClosingStructuresFailureMechanism(), assessmentSection); var failureMechanism = new ClosingStructuresFailureMechanism(); using (var view = new StructuresFailureMechanismResultView <ClosingStructuresFailureMechanism, ClosingStructuresInput>( 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(); }
public void ContextMenuStrip_ClickOnCalculateAllItem_ScheduleAllChildCalculations() { // Setup IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mocksRepository); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var failureMechanism = new ClosingStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new TestClosingStructuresCalculationScenario { Name = "A", InputParameters = { HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation() } }); failureMechanism.CalculationsGroup.Children.Add(new TestClosingStructuresCalculationScenario { Name = "B", InputParameters = { HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation() } }); 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 ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); using (var treeViewControl = new TreeViewControl()) { 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 <StructuresClosureCalculationInput>( Arg <HydraRingCalculationSettings> .Is.NotNull)) .WhenCalled(invocation => { HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings( HydraulicBoundaryCalculationSettingsFactory.CreateSettings(hydraulicBoundaryDatabase), (HydraRingCalculationSettings)invocation.Arguments[0]); }) .Return(new TestStructuresCalculator <StructuresClosureCalculationInput>()) .Repeat .Times(nrOfCalculators); mocksRepository.ReplayAll(); 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("Betrouwbaarheid sluiting kunstwerk 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("Betrouwbaarheid sluiting kunstwerk berekening is uitgevoerd op de tijdelijke locatie", messageList[11]); CalculationServiceTestHelper.AssertCalculationEndMessage(messageList[12]); Assert.AreEqual("Uitvoeren van berekening 'B' is gelukt.", messageList[13]); }); } } }
public void ContextMenuStrip_ClickOnValidateAllItem_ValidateAllChildCalculations() { // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new TestClosingStructuresCalculationScenario { Name = "A", InputParameters = { HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation() } }); failureMechanism.CalculationsGroup.Children.Add(new TestClosingStructuresCalculationScenario { Name = "B", InputParameters = { HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation() } }); 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 ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); 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; 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]); }); } } }
public void GivenCalculationsWithIllustrationPoints_WhenClearIllustrationPointsClickedAndContinued_ThenInquiryAndIllustrationPointsCleared() { // Given var calculationWithIllustrationPoints = new TestClosingStructuresCalculationScenario { Output = new TestStructuresOutput(new TestGeneralResultFaultTreeIllustrationPoint()) }; var calculationWithOutput = new TestClosingStructuresCalculationScenario { Output = new TestStructuresOutput() }; var failureMechanism = new ClosingStructuresFailureMechanism { CalculationsGroup = { Children = { calculationWithIllustrationPoints, calculationWithOutput, new TestClosingStructuresCalculationScenario() } } }; 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 ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var messageBoxText = ""; DialogBoxHandler = (name, wnd) => { var helper = new MessageBoxTester(wnd); messageBoxText = helper.Text; helper.ClickOk(); }; 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; 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); } } }