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 ClosingStructuresPlugin { Gui = gui }) { // Call ViewInfo[] viewInfos = plugin.GetViewInfos().ToArray(); // Assert Assert.AreEqual(5, viewInfos.Length); PluginTestHelper.AssertViewInfoDefined( viewInfos, typeof(CalculationsStateFailureMechanismContext), typeof(CalculationsStateFailureMechanismView)); PluginTestHelper.AssertViewInfoDefined( viewInfos, typeof(RegistrationStateFailureMechanismContext), typeof(RegistrationStateFailureMechanismView)); PluginTestHelper.AssertViewInfoDefined( viewInfos, typeof(ClosingStructuresFailureMechanismSectionResultContext), typeof(IObservableEnumerable <AdoptableFailureMechanismSectionResult>), typeof(StructuresFailureMechanismResultView <ClosingStructuresFailureMechanism, ClosingStructuresInput>)); PluginTestHelper.AssertViewInfoDefined( viewInfos, typeof(ClosingStructuresScenariosContext), typeof(CalculationGroup), typeof(ClosingStructuresScenariosView)); PluginTestHelper.AssertViewInfoDefined( viewInfos, typeof(ClosingStructuresCalculationGroupContext), typeof(CalculationGroup), typeof(ClosingStructuresCalculationsView)); viewInfos.ForEachElementDo(vi => { Assert.AreEqual(symbol, vi.GetSymbol()); Assert.AreSame(fontFamily, vi.GetFontFamily()); }); } mockRepository.VerifyAll(); }
public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var mocks = new MockRepository(); IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); mocks.ReplayAll(); var context = new ClosingStructuresCalculationGroupContext(new CalculationGroup(), null, new ClosingStructuresFailureMechanism(), assessmentSection); using (var plugin = new ClosingStructuresPlugin()) { ImportInfo info = GetImportInfo(plugin); // Call IFileImporter fileImporter = info.CreateFileImporter(context, "test"); // Assert Assert.IsInstanceOf <ClosingStructuresCalculationConfigurationImporter>(fileImporter); } mocks.VerifyAll(); }
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 ClosingStructuresPlugin { Gui = gui }) { // Call ExportInfo[] exportInfos = plugin.GetExportInfos().ToArray(); // Assert Assert.AreEqual(2, exportInfos.Length); Assert.IsTrue(exportInfos.Any(tni => tni.DataType == typeof(ClosingStructuresCalculationGroupContext))); Assert.IsTrue(exportInfos.Any(tni => tni.DataType == typeof(ClosingStructuresCalculationScenarioContext))); } mocks.VerifyAll(); }
public void IsEnabled_FailureMechanismSectionsSourcePathSet_ReturnTrue() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); string sourcePath = TestHelper.GetScratchPadPath(); failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), sourcePath); var context = new ClosingStructuresFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new ClosingStructuresPlugin()) { UpdateInfo importInfo = GetUpdateInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsTrue(isEnabled); } mocks.VerifyAll(); }
public void CurrentPath_FailureMechanismSectionsSourcePathSet_ReturnsExpectedPath() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); string sourcePath = TestHelper.GetScratchPadPath(); failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), sourcePath); var context = new ClosingStructuresFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new ClosingStructuresPlugin()) { UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call string currentFilePath = updateInfo.CurrentPath(context); // Assert Assert.AreEqual(sourcePath, currentFilePath); mocks.VerifyAll(); } }
public void VerifyUpdates_CalculationWithoutOutputs_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(); using (var plugin = new ClosingStructuresPlugin()) { plugin.Gui = gui; var failureMechanism = new ClosingStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation <ClosingStructuresInput>()); var structures = new StructureCollection <ClosingStructure>(); var context = new ClosingStructuresContext(structures, failureMechanism, assessmentSection); ImportInfo importInfo = GetImportInfo(plugin); // Call bool updatesVerified = importInfo.VerifyUpdates(context); // Assert Assert.IsTrue(updatesVerified); mocks.VerifyAll(); } }
public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); var importTarget = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection); using (var plugin = new ClosingStructuresPlugin()) { ImportInfo importInfo = GetImportInfo(plugin); // Call IFileImporter importer = importInfo.CreateFileImporter(importTarget, "test"); // Assert Assert.IsInstanceOf <ClosingStructuresImporter>(importer); } mocks.VerifyAll(); }
public void IsEnabled_ReferenceLineWithoutGeometry_ReturnFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); var context = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection); using (var plugin = new ClosingStructuresPlugin()) { ImportInfo importInfo = GetImportInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); } mocks.VerifyAll(); }
public void DefaultConstructor_ExpectedValues() { // Call using (var plugin = new ClosingStructuresPlugin()) { // Assert Assert.IsInstanceOf <PluginBase>(plugin); } }
public void VerifyUpdates_CalculationWithOutputs_AlwaysReturnsExpectedInquiryMessage(bool isActionConfirmed) { // 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(); using (var plugin = new ClosingStructuresPlugin()) { plugin.Gui = gui; var failureMechanism = new ClosingStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation <ClosingStructuresInput> { Output = new TestStructuresOutput() }); var structures = new StructureCollection <ClosingStructure>(); var context = new ClosingStructuresContext(structures, failureMechanism, assessmentSection); ImportInfo importInfo = GetImportInfo(plugin); string textBoxMessage = null; DialogBoxHandler = (name, wnd) => { var helper = new MessageBoxTester(wnd); textBoxMessage = helper.Text; if (isActionConfirmed) { helper.ClickOk(); } else { helper.ClickCancel(); } }; // Call bool updatesVerified = importInfo.VerifyUpdates(context); // Assert string expectedInquiryMessage = "Als u kunstwerken importeert, dan worden alle rekenresultaten van dit faalmechanisme verwijderd." + $"{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?"; Assert.AreEqual(expectedInquiryMessage, textBoxMessage); Assert.AreEqual(isActionConfirmed, updatesVerified); mocks.VerifyAll(); } }
public void GetUpdateInfos_ReturnSupportedUpdateInfos() { using (var plugin = new ClosingStructuresPlugin()) { // Call UpdateInfo[] updateInfo = plugin.GetUpdateInfos().ToArray(); // Assert Assert.AreEqual(2, updateInfo.Length); Assert.IsTrue(updateInfo.Any(i => i.DataType == typeof(ClosingStructuresContext))); Assert.IsTrue(updateInfo.Any(i => i.DataType == typeof(ClosingStructuresFailureMechanismSectionsContext))); } }
public void GetImportInfos_ReturnsSupportedImportInfos() { // Setup using (var plugin = new ClosingStructuresPlugin()) { // Call ImportInfo[] importInfos = plugin.GetImportInfos().ToArray(); // Assert Assert.AreEqual(2, importInfos.Length); Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(ClosingStructuresContext))); Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(ClosingStructuresCalculationGroupContext))); } }
public void Name_Always_ReturnExpectedName() { // Setup using (var plugin = new ClosingStructuresPlugin()) { ImportInfo importInfo = GetImportInfo(plugin); // Call string name = importInfo.Name; // Assert Assert.AreEqual("Kunstwerklocaties", name); } }
public void IsEnabled_Always_ReturnsTrue() { // Setup using (var plugin = new ClosingStructuresPlugin()) { ImportInfo info = GetImportInfo(plugin); // Call bool isEnabled = info.IsEnabled(null); // Assert Assert.IsTrue(isEnabled); } }
public void Image_Always_ReturnExpectedIcon() { // Setup using (var plugin = new ClosingStructuresPlugin()) { UpdateInfo importInfo = GetUpdateInfo(plugin); // Call Image image = importInfo.Image; // Assert TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.SectionsIcon, image); } }
public void Name_Always_ReturnExpectedName() { // Setup using (var plugin = new ClosingStructuresPlugin()) { UpdateInfo importInfo = GetUpdateInfo(plugin); // Call string name = importInfo.Name; // Assert Assert.AreEqual("Vakindeling", name); } }
public void Category_Always_ReturnExpectedCategory() { // Setup using (var plugin = new ClosingStructuresPlugin()) { UpdateInfo importInfo = GetUpdateInfo(plugin); // Call string category = importInfo.Category; // Assert Assert.AreEqual("Algemeen", category); } }
public void FileFilterGenerator_Always_ReturnExpectedFileFilter() { // Setup using (var plugin = new ClosingStructuresPlugin()) { UpdateInfo importInfo = GetUpdateInfo(plugin); // Call FileFilterGenerator fileFilterGenerator = importInfo.FileFilterGenerator; // Assert Assert.AreEqual("Shapebestand (*.shp)|*.shp", fileFilterGenerator.Filter); } }
public void FileFilterGenerator_Always_ReturnFileFilter() { // Setup using (var plugin = new ClosingStructuresPlugin()) { ImportInfo info = GetImportInfo(plugin); // Call FileFilterGenerator fileFilterGenerator = info.FileFilterGenerator; // Assert Assert.AreEqual("Riskeer berekeningenconfiguratie (*.xml)|*.xml", fileFilterGenerator.Filter); } }
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 ClosingStructuresPlugin { Gui = gui }; info = plugin.GetExportInfos().First(ei => ei.DataType == typeof(ClosingStructuresCalculationScenarioContext)); }
public void Initialized_Always_ExpectedPropertiesSet() { // Setup using (var plugin = new ClosingStructuresPlugin()) { // Call ImportInfo info = GetImportInfo(plugin); // Assert Assert.IsNotNull(info.CreateFileImporter); Assert.IsNotNull(info.IsEnabled); Assert.AreEqual("Riskeer berekeningenconfiguratie", info.Name); Assert.AreEqual("Algemeen", info.Category); TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.GeneralFolderIcon, info.Image); Assert.IsNotNull(info.FileFilterGenerator); } }
public void GetTreeNodeInfos_ReturnsSupportedTreeNodeInfos() { // Setup using (var plugin = new ClosingStructuresPlugin()) { // Call TreeNodeInfo[] treeNodeInfos = plugin.GetTreeNodeInfos().ToArray(); // Assert Assert.AreEqual(9, 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(ClosingStructuresFailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructuresContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructure))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructuresCalculationGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructuresCalculationScenarioContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructuresInputContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructuresScenariosContext))); } }
public void GetPropertyInfos_ReturnsSupportedPropertyInfos() { // Setup using (var plugin = new ClosingStructuresPlugin()) { // Call PropertyInfo[] propertyInfos = plugin.GetPropertyInfos().ToArray(); // Assert Assert.AreEqual(5, propertyInfos.Length); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(CalculationsStateFailureMechanismContext), typeof(CalculationsStateFailureMechanismProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(RegistrationStateFailureMechanismContext), typeof(RegistrationStateFailureMechanismProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(ClosingStructure), typeof(ClosingStructureProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(ClosingStructuresContext), typeof(StructureCollectionProperties <ClosingStructure>)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(ClosingStructuresInputContext), typeof(ClosingStructuresInputContextProperties)); } }
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 ClosingStructuresFailureMechanism(); var context = new ClosingStructuresFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new ClosingStructuresPlugin()) { UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call IFileImporter importer = updateInfo.CreateFileImporter(context, string.Empty); // Assert Assert.IsInstanceOf <FailureMechanismSectionsImporter>(importer); mocks.VerifyAll(); } }
public void IsEnabled_FailureMechanismSectionsSourcePathNull_ReturnFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); var context = new ClosingStructuresFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new ClosingStructuresPlugin()) { UpdateInfo importInfo = GetUpdateInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); } mocks.VerifyAll(); }
public void SetUp() { mocks = new MockRepository(); plugin = new ClosingStructuresPlugin(); info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(ClosingStructuresScenariosContext)); }
private static UpdateInfo GetUpdateInfo(ClosingStructuresPlugin plugin) { return(plugin.GetUpdateInfos().First(ii => ii.DataType == typeof(ClosingStructuresFailureMechanismSectionsContext))); }
private static ImportInfo GetImportInfo(ClosingStructuresPlugin plugin) { return(plugin.GetImportInfos().First(ei => ei.DataType == typeof(ClosingStructuresCalculationGroupContext))); }
public void Setup() { plugin = new ClosingStructuresPlugin(); info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(ClosingStructuresFailureMechanismSectionResultContext)); }
public void SetUp() { mocks = new MockRepository(); plugin = new ClosingStructuresPlugin(); info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(StructuresFailureMechanismResultView <ClosingStructuresFailureMechanism, ClosingStructuresInput>)); }