Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
        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();
        }