Ejemplo n.º 1
0
        public static void Test(String tempFolderName, String sourceSubfolderPath)
        {
            String subfolderName = Path.GetFileName(sourceSubfolderPath);

            String tempFolder     = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.WorkDirectory, @"Temp\XlsxConverterTesting"));
            String tempFolderPath = Path.Combine(tempFolder, subfolderName);

            String xlsxFilePath     = GetFilePath(Path.Combine(sourceSubfolderPath, "source.xlsx"));
            String templateFilePath = GetFilePath(Path.Combine(sourceSubfolderPath, "template.csv"));
            String csvFilePath      = PrepareCsvFile(Path.Combine(tempFolder, tempFolderName, subfolderName, "result.csv"));

            using (StreamWriter streamWriter = new StreamWriter(csvFilePath))
            {
                CsvWriter csvWriter = new CsvWriter(streamWriter);
                MoqDelimitedTextWriter delimitedTextWriter = new MoqDelimitedTextWriter(csvWriter);
                XlsxConverter.Convert(xlsxFilePath, delimitedTextWriter);
                delimitedTextWriter.Flush();
                streamWriter.Flush();
            }

            FileAssert.AreEqual(csvFilePath, templateFilePath);
        }
Ejemplo n.º 2
0
 public void Test_001()
 {
     Assert.Catch <ActiveWorksheetException>(
         () =>
     {
         String xlsxFilePath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\XlsxConverterTesting\Tester+Files\001\source.xlsx"));
         String csvFilePath  = Path.GetTempFileName();
         try
         {
             using (StreamWriter streamWriter = new StreamWriter(csvFilePath))
             {
                 CsvWriter csvWriter = new CsvWriter(streamWriter);
                 MoqDelimitedTextWriter delimitedTextWriter = new MoqDelimitedTextWriter(csvWriter);
                 XlsxConverter.Convert(xlsxFilePath, delimitedTextWriter);
                 csvWriter.Flush();
                 streamWriter.Flush();
             }
         }
         finally
         {
             File.Delete(csvFilePath);
         }
     });
 }