예제 #1
0
        /// <summary>
        /// Internal method to process excel file with expected worksheets
        /// </summary>
        /// <param name="fileName">fileName (note that this file should be placed in TestData folder</param>
        /// <param name="expectedCsvFiles">the expected count of correct worksheets</param>
        private void TestCreateCsv(string fileName, int expectedCsvFiles)
        {
            string nameForOutputDirectory = Path.Combine(Environment.CurrentDirectory, "TestData", DateTime.Now.Ticks.ToString());

            Directory.CreateDirectory(nameForOutputDirectory); // create directory for output csv

            ProcessExcel.CreateCsv(Path.Combine(Environment.CurrentDirectory, "TestData", fileName), nameForOutputDirectory + "\\");

            var filesCollection = Directory.GetFiles(nameForOutputDirectory, "*.csv");

            Directory.Delete(nameForOutputDirectory, true);            // delete temp data (NOTE, we do this before Assert to avoid dirty folders)

            Assert.AreEqual(expectedCsvFiles, filesCollection.Length); // it should be expectedCsvFiles count of csv files
        }
예제 #2
0
        private static void Main(string[] args)
        {
            string error;

            if (CheckArgs(args, out error))
            {
                ProcessExcel.CreateCsv(args[0], args[1]);
            }
            else
            {
                Console.WriteLine(error);
                Console.WriteLine("Error have been occured while processing ");
            }
        }
예제 #3
0
 /// <summary>
 /// Test that we'll correctly process situation when we try to write in unexisting folder
 /// </summary>
 ////[TestMethod]
 public void TestUnexistingFolder()
 {
     try
     {
         string unexistedFolder;
         do
         {
             unexistedFolder = "E:\\" + DateTime.Now.Ticks.ToString();
         } while (Directory.Exists(unexistedFolder));
         ProcessExcel.CreateCsv(Path.Combine(Environment.CurrentDirectory, "TestData", "TestExcel2003.xls"), unexistedFolder + "\\");
     }
     catch (DirectoryNotFoundException)
     {
         //good exception
     }
 }