public void CurrentPath_FailureMechanismSectionsSourcePathSet_ReturnsExpectedPath() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new StabilityStoneCoverFailureMechanism(); string sourcePath = TestHelper.GetScratchPadPath(); failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), sourcePath); var context = new StabilityStoneCoverFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new StabilityStoneCoverPlugin()) { UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call string currentFilePath = updateInfo.CurrentPath(context); // Assert Assert.AreEqual(sourcePath, currentFilePath); mocks.VerifyAll(); } }
public void GetPropertyInfos_ReturnsSupportedPropertyInfos() { // Setup using (var plugin = new StabilityStoneCoverPlugin()) { // Call PropertyInfo[] propertyInfos = plugin.GetPropertyInfos().ToArray(); // Assert Assert.AreEqual(4, propertyInfos.Length); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(HydraulicLoadsStateFailureMechanismContext), typeof(HydraulicLoadsStateFailureMechanismProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(RegistrationStateFailureMechanismContext), typeof(RegistrationStateFailureMechanismProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(StabilityStoneCoverWaveConditionsOutputContext), typeof(StabilityStoneCoverWaveConditionsOutputProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(StabilityStoneCoverWaveConditionsInputContext), typeof(StabilityStoneCoverWaveConditionsInputContextProperties)); } }
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 StabilityStoneCoverPlugin { Gui = gui }) { // Call ExportInfo[] exportInfos = plugin.GetExportInfos().ToArray(); // Assert Assert.AreEqual(4, exportInfos.Length); Assert.AreEqual(2, exportInfos.Count(ei => ei.DataType == typeof(StabilityStoneCoverCalculationGroupContext))); Assert.AreEqual(2, exportInfos.Count(ei => ei.DataType == typeof(StabilityStoneCoverWaveConditionsCalculationContext))); } mocks.VerifyAll(); }
public void Initialized_Always_ExpectedPropertiesSet() { // Setup using (var plugin = new StabilityStoneCoverPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Assert Assert.IsNotNull(info.Text); Assert.IsNull(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 CreateInstance_WithContextThatHasInputWithSpecificWaterLevelType_ExpectedProperties( IAssessmentSection assessmentSection, Action <WaveConditionsInput> configureInputAction, RoundedDouble expectedAssessmentLevel) { // Setup var calculation = new StabilityStoneCoverWaveConditionsCalculation(); configureInputAction(calculation.InputParameters); var context = new StabilityStoneCoverWaveConditionsInputContext(calculation.InputParameters, calculation, assessmentSection, Array.Empty <ForeshoreProfile>()); using (var plugin = new StabilityStoneCoverPlugin()) { PropertyInfo info = GetInfo(plugin); // Call IObjectProperties objectProperties = info.CreateInstance(context); // Assert Assert.IsInstanceOf <StabilityStoneCoverWaveConditionsInputContextProperties>(objectProperties); Assert.AreSame(context, objectProperties.Data); Assert.AreEqual(expectedAssessmentLevel, ((StabilityStoneCoverWaveConditionsInputContextProperties)objectProperties).AssessmentLevel); } }
public void IsEnabled_FailureMechanismSectionsSourcePathSet_ReturnTrue() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new StabilityStoneCoverFailureMechanism(); string sourcePath = TestHelper.GetScratchPadPath(); failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), sourcePath); var context = new StabilityStoneCoverFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new StabilityStoneCoverPlugin()) { UpdateInfo importInfo = GetUpdateInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsTrue(isEnabled); } mocks.VerifyAll(); }
public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { // Setup var mocks = new MockRepository(); using (var treeViewControl = new TreeViewControl()) { StabilityStoneCoverWaveConditionsOutput output = StabilityStoneCoverWaveConditionsOutputTestFactory.Create(); var context = new StabilityStoneCoverWaveConditionsOutputContext(output, new StabilityStoneCoverWaveConditionsInput()); var menuBuilder = mocks.StrictMock <IContextMenuBuilder>(); using (mocks.Ordered()) { 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(); using (var plugin = new StabilityStoneCoverPlugin()) { TreeNodeInfo info = GetInfo(plugin); plugin.Gui = gui; // Call info.ContextMenuStrip(context, null, treeViewControl); } } // Assert mocks.VerifyAll(); }
public void CreateInstance_WithContext_SetsFailureMechanismAsData() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new StabilityStoneCoverFailureMechanism(); var context = new StabilityStoneCoverFailureMechanismContext(failureMechanism, assessmentSection); using (var plugin = new StabilityStoneCoverPlugin()) { PropertyInfo info = GetInfo(plugin); // Call IObjectProperties objectProperties = info.CreateInstance(context); // Assert Assert.IsInstanceOf <StabilityStoneCoverFailureMechanismProperties>(objectProperties); Assert.AreSame(failureMechanism, objectProperties.Data); } mocks.VerifyAll(); }
public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { // Setup var mocks = new MockRepository(); using (var treeViewControl = new TreeViewControl()) { 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.AddPropertiesItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); } var gui = mocks.Stub <IGui>(); gui.Stub(cmp => cmp.Get(null, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); using (var plugin = new StabilityStoneCoverPlugin()) { TreeNodeInfo info = GetInfo(plugin); plugin.Gui = gui; // Call info.ContextMenuStrip(null, null, treeViewControl); } } // Assert mocks.VerifyAll(); }
public void GetViewInfos_ReturnsSupportedViewInfos() { // Setup const string symbol = "<symbol>"; var fontFamily = new FontFamily(); var mockRepository = new MockRepository(); var gui = mockRepository.Stub <IGui>(); gui.Stub(g => g.ActiveStateInfo).Return(new StateInfo(string.Empty, symbol, fontFamily, p => p)); mockRepository.ReplayAll(); using (var plugin = new StabilityStoneCoverPlugin { Gui = gui }) { // Call ViewInfo[] viewInfos = plugin.GetViewInfos().ToArray(); // Assert Assert.AreEqual(4, viewInfos.Length); PluginTestHelper.AssertViewInfoDefined( viewInfos, typeof(HydraulicLoadsStateFailureMechanismContext), typeof(HydraulicLoadsStateFailureMechanismView)); PluginTestHelper.AssertViewInfoDefined( viewInfos, typeof(RegistrationStateFailureMechanismContext), typeof(RegistrationStateFailureMechanismView)); PluginTestHelper.AssertViewInfoDefined( viewInfos, typeof(StabilityStoneCoverFailureMechanismSectionResultContext), typeof(IObservableEnumerable <NonAdoptableWithProfileProbabilityFailureMechanismSectionResult>), typeof(NonAdoptableWithProfileProbabilityFailureMechanismResultView <StabilityStoneCoverFailureMechanism>)); PluginTestHelper.AssertViewInfoDefined( viewInfos, typeof(StabilityStoneCoverWaveConditionsInputContext), typeof(StabilityStoneCoverWaveConditionsCalculation), typeof(WaveConditionsInputView)); viewInfos.ForEachElementDo(vi => { Assert.AreEqual(symbol, vi.GetSymbol()); Assert.AreSame(fontFamily, vi.GetFontFamily()); }); } mockRepository.VerifyAll(); }
public void Initialized_Always_ExpectedPropertiesSet() { // Setup using (var plugin = new StabilityStoneCoverPlugin()) { // Call PropertyInfo info = GetInfo(plugin); // Assert Assert.AreEqual(typeof(StabilityStoneCoverWaveConditionsOutputContext), info.DataType); Assert.AreEqual(typeof(StabilityStoneCoverWaveConditionsOutputProperties), info.PropertyObjectType); } }
public void GetImportInfos_ReturnsSupportedImportInfos() { // Setup using (var plugin = new StabilityStoneCoverPlugin()) { // Call ImportInfo[] importInfos = plugin.GetImportInfos().ToArray(); // Assert Assert.AreEqual(1, importInfos.Length); Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(StabilityStoneCoverCalculationGroupContext))); } }
public void GetUpdateInfos_ReturnsSupportedUpdateInfos() { // Setup using (var plugin = new StabilityStoneCoverPlugin()) { // Call UpdateInfo[] updateInfos = plugin.GetUpdateInfos().ToArray(); // Assert Assert.AreEqual(1, updateInfos.Length); Assert.AreEqual(1, updateInfos.Count(ei => ei.DataType == typeof(StabilityStoneCoverFailureMechanismSectionsContext))); } }
public void Category_Always_ReturnExpectedCategory() { // Setup using (var plugin = new StabilityStoneCoverPlugin()) { UpdateInfo importInfo = GetUpdateInfo(plugin); // Call string category = importInfo.Category; // Assert Assert.AreEqual("Algemeen", category); } }
public void Text_Always_ReturnName() { // Setup using (var plugin = new StabilityStoneCoverPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call string nodeText = info.Text(null); // Assert Assert.AreEqual("Invoer", nodeText); } }
public void Image_Always_ReturnExpectedIcon() { // Setup using (var plugin = new StabilityStoneCoverPlugin()) { UpdateInfo importInfo = GetUpdateInfo(plugin); // Call Image image = importInfo.Image; // Assert TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.SectionsIcon, image); } }
public void FileFilterGenerator_Always_ReturnExpectedFileFilter() { // Setup using (var plugin = new StabilityStoneCoverPlugin()) { UpdateInfo importInfo = GetUpdateInfo(plugin); // Call FileFilterGenerator fileFilterGenerator = importInfo.FileFilterGenerator; // Assert Assert.AreEqual("Shapebestand (*.shp)|*.shp", fileFilterGenerator.Filter); } }
public void Name_Always_ReturnExpectedName() { // Setup using (var plugin = new StabilityStoneCoverPlugin()) { UpdateInfo importInfo = GetUpdateInfo(plugin); // Call string name = importInfo.Name; // Assert Assert.AreEqual("Vakindeling", name); } }
public void Image_Always_ReturnOutputIcon() { // Setup using (var plugin = new StabilityStoneCoverPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call Image icon = info.Image(null); // Assert TestHelper.AssertImagesAreEqual(Resources.GenericInputOutputIcon, icon); } }
public void Image_Always_ReturnOutputIcon() { // Setup var output = new EmptyStabilityStoneCoverOutput(); using (var plugin = new StabilityStoneCoverPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call Image icon = info.Image(output); // Assert TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.GeneralOutputIcon, icon); } }
public void ForeColor_Always_ReturnGrayText() { // Setup var output = new EmptyStabilityStoneCoverOutput(); using (var plugin = new StabilityStoneCoverPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call Color color = info.ForeColor(output); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); } }
public void Text_Always_ReturnName() { // Setup var output = new EmptyStabilityStoneCoverOutput(); using (var plugin = new StabilityStoneCoverPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call string nodeText = info.Text(output); // Assert Assert.AreEqual("Resultaat", nodeText); } }
public void CreateInstance_WithContext_SetsOutputAsData() { // Setup StabilityStoneCoverWaveConditionsOutput output = StabilityStoneCoverWaveConditionsOutputTestFactory.Create(); var context = new StabilityStoneCoverWaveConditionsOutputContext(output, new StabilityStoneCoverWaveConditionsInput()); using (var plugin = new StabilityStoneCoverPlugin()) { PropertyInfo info = GetInfo(plugin); // Call IObjectProperties objectProperties = info.CreateInstance(context); // Assert Assert.IsInstanceOf <StabilityStoneCoverWaveConditionsOutputProperties>(objectProperties); Assert.AreSame(output, objectProperties.Data); } }
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 StabilityStoneCoverPlugin { Gui = gui }; info = plugin.GetExportInfos() .Single(ei => ei.DataType == typeof(StabilityStoneCoverWaveConditionsCalculationContext) && ei.Name(null).Equals("Riskeer berekeningenconfiguratie")); }
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 StabilityStoneCoverPlugin { Gui = gui }; info = plugin.GetExportInfos() .Single(ei => ei.DataType == typeof(StabilityStoneCoverCalculationGroupContext) && ei.Name(null).Equals("Berekende belastingen bij verschillende waterstanden")); }
public void GetTreeNodeInfos_ReturnsSupportedTreeNodeInfos() { // Setup using (var plugin = new StabilityStoneCoverPlugin()) { // Call TreeNodeInfo[] treeNodeInfos = plugin.GetTreeNodeInfos().ToArray(); // Assert Assert.AreEqual(8, treeNodeInfos.Length); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HydraulicLoadsStateFailureMechanismContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(RegistrationStateFailureMechanismContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverCalculationGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverWaveConditionsCalculationContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(EmptyStabilityStoneCoverOutput))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverFailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverWaveConditionsOutputContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverWaveConditionsInputContext))); } }
public void IsEnabled_FailureMechanismSectionsSourcePathNull_ReturnFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new StabilityStoneCoverFailureMechanism(); var context = new StabilityStoneCoverFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new StabilityStoneCoverPlugin()) { UpdateInfo importInfo = GetUpdateInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); } mocks.VerifyAll(); }
public void CreateFileImporter_WithValidData_ReturnsFileImporter() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var failureMechanism = new StabilityStoneCoverFailureMechanism(); var context = new StabilityStoneCoverFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new StabilityStoneCoverPlugin()) { UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call IFileImporter importer = updateInfo.CreateFileImporter(context, string.Empty); // Assert Assert.IsInstanceOf <FailureMechanismSectionsImporter>(importer); mocks.VerifyAll(); } }
public void SetUp() { mocks = new MockRepository(); plugin = new StabilityStoneCoverPlugin(); info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(StabilityStoneCoverFailureMechanismView)); }
private static PropertyInfo GetInfo(StabilityStoneCoverPlugin plugin) { return(plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(StabilityStoneCoverWaveConditionsOutputContext))); }