public void GetExportInfos_ReturnsSupportedExportInfos() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); mocks.ReplayAll(); using (var plugin = new PipingPlugin { Gui = gui }) { // Call ExportInfo[] exportInfos = plugin.GetExportInfos().ToArray(); // Assert Assert.AreEqual(3, exportInfos.Length); Assert.IsTrue(exportInfos.Any(tni => tni.DataType == typeof(PipingCalculationGroupContext))); Assert.IsTrue(exportInfos.Any(tni => tni.DataType == typeof(SemiProbabilisticPipingCalculationScenarioContext))); Assert.IsTrue(exportInfos.Any(tni => tni.DataType == typeof(ProbabilisticPipingCalculationScenarioContext))); } mocks.VerifyAll(); }
public void Name_Always_ReturnExpectedName() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); mocks.ReplayAll(); using (var plugin = new PipingPlugin()) { plugin.Gui = gui; UpdateInfo importInfo = GetUpdateInfo(plugin); // Call string name = importInfo.Name; // Assert Assert.AreEqual("Vakindeling", name); } mocks.VerifyAll(); }
public void Image_Always_ReturnExpectedIcon() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); mocks.ReplayAll(); using (var plugin = new PipingPlugin()) { plugin.Gui = gui; UpdateInfo importInfo = GetUpdateInfo(plugin); // Call Image image = importInfo.Image; // Assert TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.SectionsIcon, image); } mocks.VerifyAll(); }
public void IsEnabled_FailureMechanismSectionsSourcePathSet_ReturnTrue() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); string sourcePath = TestHelper.GetScratchPadPath(); failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), sourcePath); var context = new PipingFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new PipingPlugin()) { plugin.Gui = gui; UpdateInfo importInfo = GetUpdateInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsTrue(isEnabled); } mocks.VerifyAll(); }
public void Category_Always_ReturnExpectedCategory() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); mocks.ReplayAll(); using (var plugin = new PipingPlugin()) { plugin.Gui = gui; UpdateInfo importInfo = GetUpdateInfo(plugin); // Call string category = importInfo.Category; // Assert Assert.AreEqual("Algemeen", category); } mocks.VerifyAll(); }
public void ForeColor_HasSectionsOnFailureMechanism_ReturnControlText() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); failureMechanism.SetSections(new[] { new FailureMechanismSection("A", new[] { new Point2D(3, 4), new Point2D(5, 6) }) }, "B"); var context = new PipingFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new PipingPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call Color color = info.ForeColor(context); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color); } mocks.VerifyAll(); }
public void GetUpdateInfos_ReturnsSupportedUpdateInfos() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); mocks.ReplayAll(); using (var plugin = new PipingPlugin { Gui = gui }) { // Call UpdateInfo[] updateInfos = plugin.GetUpdateInfos().ToArray(); // Assert Assert.AreEqual(3, updateInfos.Length); Assert.AreEqual(1, updateInfos.Count(updateInfo => updateInfo.DataType == typeof(PipingSurfaceLinesContext))); Assert.AreEqual(1, updateInfos.Count(updateInfo => updateInfo.DataType == typeof(PipingStochasticSoilModelCollectionContext))); Assert.AreEqual(1, updateInfos.Count(updateInfo => updateInfo.DataType == typeof(PipingFailureMechanismSectionsContext))); } mocks.VerifyAll(); }
public void CreateFileImporter_WithValidData_ReturnsFileImporter() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); var context = new PipingFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new PipingPlugin()) { plugin.Gui = gui; UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call IFileImporter importer = updateInfo.CreateFileImporter(context, string.Empty); // Assert Assert.IsInstanceOf <FailureMechanismSectionsImporter>(importer); } mocks.VerifyAll(); }
public void SetUp() { using (var plugin = new PipingPlugin()) { info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(FailureMechanismSectionsProbabilityAssessmentView)); } }
public void GetTreeNodeInfos_ReturnsSupportedTreeNodeInfos() { // Setup using (var plugin = new PipingPlugin()) { // Call TreeNodeInfo[] treeNodeInfos = plugin.GetTreeNodeInfos().ToArray(); // Assert Assert.AreEqual(20, treeNodeInfos.Length); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(CalculationsStateFailureMechanismContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(RegistrationStateFailureMechanismContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingSurfaceLinesContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingSurfaceLine))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingStochasticSoilModelCollectionContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingStochasticSoilModel))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingStochasticSoilProfile))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(SemiProbabilisticPipingCalculationScenarioContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingCalculationGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(SemiProbabilisticPipingInputContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingFailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(SemiProbabilisticPipingOutputContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingScenariosContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(EmptySemiProbabilisticPipingOutput))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ProbabilisticPipingCalculationScenarioContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ProbabilisticPipingInputContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ProbabilisticPipingOutputContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ProbabilisticPipingSectionSpecificOutputContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ProbabilisticPipingProfileSpecificOutputContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingFailureMechanismSectionsContext))); } }
public void CurrentPath_FailureMechanismSectionsSourcePathSet_ReturnsExpectedPath() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); string sourcePath = TestHelper.GetScratchPadPath(); failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), sourcePath); var context = new PipingFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new PipingPlugin()) { plugin.Gui = gui; UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call string currentFilePath = updateInfo.CurrentPath(context); // Assert Assert.AreEqual(sourcePath, currentFilePath); } mocks.VerifyAll(); }
public void VerifyUpdates_ProbabilisticCalculationsWithoutOutput_ReturnsTrue() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new ProbabilisticPipingCalculationScenario()); var context = new PipingFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new PipingPlugin()) { plugin.Gui = gui; UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call bool updatesVerified = updateInfo.VerifyUpdates(context); // Assert Assert.IsTrue(updatesVerified); } mocks.VerifyAll(); }
public void Initialized_Always_ExpectedPropertiesSet() { // Setup using (var plugin = new PipingPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Assert Assert.IsNotNull(info.Text); Assert.IsNotNull(info.ForeColor); Assert.IsNotNull(info.Image); Assert.IsNotNull(info.ContextMenuStrip); Assert.IsNull(info.EnsureVisibleOnCreate); Assert.IsNull(info.ExpandOnCreate); Assert.IsNull(info.ChildNodeObjects); Assert.IsNull(info.CanRename); Assert.IsNull(info.OnNodeRenamed); Assert.IsNull(info.CanRemove); Assert.IsNull(info.OnNodeRemoved); Assert.IsNull(info.CanCheck); Assert.IsNull(info.CheckedState); Assert.IsNull(info.OnNodeChecked); Assert.IsNull(info.CanDrag); Assert.IsNull(info.CanDrop); Assert.IsNull(info.CanInsert); Assert.IsNull(info.OnDrop); } }
public void FileFilterGenerator_Always_ReturnExpectedFileFilter() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); mocks.ReplayAll(); using (var plugin = new PipingPlugin()) { plugin.Gui = gui; UpdateInfo importInfo = GetUpdateInfo(plugin); // Call FileFilterGenerator fileFilterGenerator = importInfo.FileFilterGenerator; // Assert Assert.AreEqual("Shapebestand (*.shp)|*.shp", fileFilterGenerator.Filter); } mocks.VerifyAll(); }
public void IsEnabled_FailureMechanismSectionsSourcePathNull_ReturnFalse() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); var context = new PipingFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new PipingPlugin()) { plugin.Gui = gui; UpdateInfo importInfo = GetUpdateInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); } mocks.VerifyAll(); }
public void DefaultConstructor_ExpectedValues() { // Call using (var plugin = new PipingPlugin()) { // Assert Assert.IsInstanceOf <PluginBase>(plugin); } }
protected override bool ShouldCloseMethod(IView view, object o) { using (var plugin = new PipingPlugin()) { return(plugin.GetViewInfos() .First(tni => tni.ViewType == typeof(ProbabilisticSubMechanismPipingOutputView)) .CloseForData(view, o)); } }
public void VerifyUpdates_CalculationWithOutputs_AlwaysReturnsExpectedInquiryMessage(bool isActionConfirmed) { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); TestPipingFailureMechanism failureMechanism = TestPipingFailureMechanism.GetFailureMechanismWithSurfaceLinesAndStochasticSoilModels(); var calculationWithOutput = new ProbabilisticPipingCalculationScenario { Output = PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithIllustrationPoints() }; failureMechanism.CalculationsGroup.Children.Add(calculationWithOutput); var context = new PipingFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new PipingPlugin()) { plugin.Gui = gui; string textBoxMessage = null; DialogBoxHandler = (name, wnd) => { var helper = new MessageBoxTester(wnd); textBoxMessage = helper.Text; if (isActionConfirmed) { helper.ClickOk(); } else { helper.ClickCancel(); } }; UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call bool updatesVerified = updateInfo.VerifyUpdates(context); // Assert string expectedInquiryMessage = "Als u de vakindeling wijzigt, dan worden de resultaten van alle probabilistische piping berekeningen verwijderd." + $"{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?"; Assert.AreEqual(expectedInquiryMessage, textBoxMessage); Assert.AreEqual(isActionConfirmed, updatesVerified); } mocks.VerifyAll(); }
public void ContextMenuStrip_WithAddImportItem_CorrectImportInfosPassed() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); var menuBuilder = mocks.StrictMock <IContextMenuBuilder>(); menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddImportItem()) .IgnoreArguments() .WhenCalled(invocation => { var importInfos = (ImportInfo[])invocation.Arguments[0]; Assert.AreEqual(1, importInfos.Length); Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(PipingFailureMechanismSectionsContext))); }) .Return(menuBuilder); menuBuilder.Expect(mb => mb.AddUpdateItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); var assessmentSection = mocks.Stub <IAssessmentSection>(); var context = new PipingFailureMechanismSectionsContext(new PipingFailureMechanism(), assessmentSection); using (var treeViewControl = new TreeViewControl()) { gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); using (var plugin = new PipingPlugin()) { TreeNodeInfo info = GetInfo(plugin); plugin.Gui = gui; // Call info.ContextMenuStrip(context, null, treeViewControl); } } // Assert mocks.VerifyAll(); }
public void Text_Always_ReturnsName() { // Setup using (var plugin = new PipingPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call string text = info.Text(null); // Assert Assert.AreEqual("Vakindeling", text); } }
public void Image_Always_ReturnSectionsIcon() { // Setup using (var plugin = new PipingPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call Image image = info.Image(null); // Assert TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.SectionsIcon, image); } }
public void GetImportInfos_ReturnsSupportedImportInfos() { // Setup using (var plugin = new PipingPlugin()) { // Call ImportInfo[] importInfos = plugin.GetImportInfos().ToArray(); // Assert Assert.AreEqual(3, importInfos.Length); Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(PipingSurfaceLinesContext))); Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(PipingStochasticSoilModelCollectionContext))); Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(PipingCalculationGroupContext))); } }
public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); var menuBuilder = mocks.StrictMock <IContextMenuBuilder>(); using (mocks.Ordered()) { menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddImportItem()).IgnoreArguments().Return(menuBuilder); menuBuilder.Expect(mb => mb.AddUpdateItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); } var assessmentSection = mocks.Stub <IAssessmentSection>(); var context = new PipingFailureMechanismSectionsContext(new PipingFailureMechanism(), assessmentSection); using (var treeViewControl = new TreeViewControl()) { gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); using (var plugin = new PipingPlugin()) { TreeNodeInfo info = GetInfo(plugin); plugin.Gui = gui; // Call info.ContextMenuStrip(context, null, treeViewControl); } } // Assert mocks.VerifyAll(); }
public void SetUp() { mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); mocks.Replay(gui); mocks.Replay(mainWindow); plugin = new PipingPlugin { Gui = gui }; info = plugin.GetExportInfos().First(ei => ei.DataType == typeof(SemiProbabilisticPipingCalculationScenarioContext)); }
public void ForeColor_NoSectionsOnFailureMechanism_ReturnGrayText() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); var context = new PipingFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new PipingPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call Color color = info.ForeColor(context); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); } mocks.VerifyAll(); }
public void SetUp() { plugin = new PipingPlugin(); info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(PipingFailureMechanismProperties)); }
public void SetUp() { mocks = new MockRepository(); plugin = new PipingPlugin(); info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(SemiProbabilisticPipingInputContext)); }
public void SetUp() { plugin = new PipingPlugin(); info = plugin.GetPropertyInfos().First(tni => tni.DataType == typeof(ProbabilisticPipingSectionSpecificOutputContext)); }
public void SetUp() { mocks = new MockRepository(); plugin = new PipingPlugin(); info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(PipingFailureMechanismResultView)); }
public void SetUp() { plugin = new PipingPlugin(); info = plugin.GetViewInfos().First(tni => tni.DataType == typeof(ProbabilisticPipingSectionSpecificOutputContext) && tni.ViewType == typeof(ProbabilisticSubMechanismPipingOutputView)); }