public void CreateCalculationGroupConfigurationExportInfo_WithArguments_ExpectedPropertiesSet() { // Setup var mocks = new MockRepository(); var fileImporter = mocks.Stub <IFileExporter>(); var inquiryHelper = mocks.Stub <IInquiryHelper>(); mocks.ReplayAll(); Func <ICalculationContext <CalculationGroup, ICalculatableFailureMechanism>, bool> isEnabled = context => false; Func <ICalculationContext <CalculationGroup, ICalculatableFailureMechanism>, string, IFileExporter> createFileExporter = (context, s) => fileImporter; // Call ExportInfo <ICalculationContext <CalculationGroup, ICalculatableFailureMechanism> > exportInfo = RiskeerExportInfoFactory.CreateCalculationGroupConfigurationExportInfo(createFileExporter, isEnabled, inquiryHelper); // Assert Assert.AreSame(isEnabled, exportInfo.IsEnabled); Assert.AreSame(createFileExporter, exportInfo.CreateFileExporter); Assert.AreEqual("Riskeer berekeningenconfiguratie", exportInfo.Name(null)); Assert.AreEqual("xml", exportInfo.Extension); Assert.AreEqual("Algemeen", exportInfo.Category); TestHelper.AssertImagesAreEqual(CoreGuiResources.ExportIcon, exportInfo.Image); Assert.IsNotNull(exportInfo.GetExportPath); mocks.VerifyAll(); }
private static void ExportItem(ExportInfo exportInfo, object source) { string exportFilePath = exportInfo.GetExportPath(); string exportInfoName = exportInfo.Name(source); if (exportFilePath != null) { log.InfoFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Start_exporting_DataType_0_, exportInfoName); IFileExporter exporter = exportInfo.CreateFileExporter(source, exportFilePath); if (exporter.Export()) { log.InfoFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Data_exported_to_File_0, exportFilePath); log.InfoFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Export_of_DataType_0_successful, exportInfoName); } else { log.ErrorFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Export_of_DataType_0_failed, exportInfoName); } } }
public void Name_Always_ReturnsName() { // Call string name = info.Name(null); // Assert Assert.AreEqual("Riskeer berekeningenconfiguratie", name); }
private static string GetItemName(ExportInfo exportInfo, object source) { string exportInfoName = exportInfo.Name(source); return(exportInfo.Extension != null ? string.Format(Resources.GetItemName_Name_0_FileExtension_1, exportInfoName, exportInfo.Extension) : exportInfoName); }
public void Name_Always_ReturnsName() { // Setup using (var plugin = new RiskeerPlugin()) { ExportInfo info = GetExportInfo(plugin); // Call string name = info.Name(null); // Assert Assert.AreEqual("Referentielijn", name); } }
public void Name_Always_ReturnsName() { // Setup using (var plugin = new RiskeerPlugin()) { ExportInfo info = GetExportInfo(plugin); // Call string name = info.Name(null); // Assert Assert.AreEqual("Golfhoogten bij vrije doelkans", name); } }
public void Name_Always_ReturnsName() { // Setup using (var plugin = new DuneErosionPlugin()) { ExportInfo info = GetExportInfo(plugin); // Call string name = info.Name(null); // Assert Assert.AreEqual("Hydraulische belastingen", name); } }
public void ImplicitOperator_OptionalDelegatesAndPropertiesSet_ExportInfoFullyConverted() { // Setup var mocks = new MockRepository(); var fileExporter = mocks.StrictMock <IFileExporter>(); mocks.ReplayAll(); const string name = "name"; const string extension = ".txt"; const string category = "category"; var image = new Bitmap(16, 16); const string exportPath = "C:/path"; var info = new ExportInfo <int> { CreateFileExporter = (data, filePath) => fileExporter, IsEnabled = data => false, Name = data => name, Extension = extension, Category = category, Image = image, GetExportPath = () => exportPath }; // Precondition Assert.IsInstanceOf <ExportInfo <int> >(info); // Call ExportInfo convertedInfo = info; // Assert Assert.IsInstanceOf <ExportInfo>(convertedInfo); Assert.AreEqual(typeof(int), convertedInfo.DataType); Assert.IsNotNull(convertedInfo.CreateFileExporter); Assert.AreSame(fileExporter, convertedInfo.CreateFileExporter(12, string.Empty)); Assert.IsNotNull(convertedInfo.IsEnabled); Assert.IsFalse(convertedInfo.IsEnabled(12)); Assert.AreEqual(name, info.Name(12)); Assert.AreEqual(extension, info.Extension); Assert.AreEqual(category, info.Category); Assert.AreSame(image, info.Image); Assert.AreEqual(exportPath, info.GetExportPath()); mocks.VerifyAll(); }
public void Name_WithContext_ReturnsName() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var context = new WaterLevelCalculationsForUserDefinedTargetProbabilityContext( new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1), assessmentSection); using (var plugin = new RiskeerPlugin()) { ExportInfo info = GetExportInfo(plugin); // Call string name = info.Name(context); // Assert Assert.AreEqual("Waterstanden (1/10)", name); } mocks.VerifyAll(); }
public void ExportFrom_MultipleSupportedExportersAvailableWithCustomSelectionDialogStyling_GivesExpectedSelectionDialog(bool hasFileExtension) { // Setup var mockRepository = new MockRepository(); var mainWindow = mockRepository.Stub <IMainWindow>(); mockRepository.ReplayAll(); var dialogText = ""; TestListViewItem[] listViewItems = null; ModalFormHandler = (name, wnd, form) => { var dialog = new FormTester(name); var imageList = TypeUtils.GetField <ImageList>(dialog.TheObject, "imageList"); var listView = (ListView) new ControlTester("listViewItemTypes").TheObject; dialogText = dialog.Text; listViewItems = listView.Items .OfType <ListViewItem>() .Select(lvi => new TestListViewItem(lvi.Name, lvi.Group.Name, imageList.Images[lvi.ImageIndex])) .ToArray(); dialog.Close(); }; var exportInfo1 = new ExportInfo <int> { Name = i => "Name 1", Category = "Category 1", Image = Resources.Busy_indicator, Extension = hasFileExtension ? "extension 1" : null }; var exportInfo2 = new ExportInfo <int> { Name = i => "Name 2", Category = "Category 2", Image = Resources.DeleteIcon, Extension = hasFileExtension ? "extension 2" : null }; var exportHandler = new GuiExportHandler(mainWindow, new List <ExportInfo> { exportInfo1, exportInfo2 }); // Call exportHandler.ExportFrom(1234); // Assert Assert.AreEqual("Kies wat u wilt exporteren", dialogText); Assert.AreEqual(2, listViewItems.Length); string exportInfo1Name = exportInfo1.Name(1234); string expectedItemName1 = hasFileExtension ? $"{exportInfo1Name} (*.{exportInfo1.Extension})" : exportInfo1Name; Assert.AreEqual(expectedItemName1, listViewItems[0].Name); Assert.AreEqual(exportInfo1.Category, listViewItems[0].Group); string exportInfo2Name = exportInfo2.Name(1234); string expectedItemName2 = hasFileExtension ? $"{exportInfo2Name} (*.{exportInfo2.Extension})" : exportInfo2Name; Assert.AreEqual(expectedItemName2, listViewItems[1].Name); Assert.AreEqual(exportInfo2.Category, listViewItems[1].Group); mockRepository.VerifyAll(); }