Exemple #1
0
        static void Main(string[] args)
        {
            string[] csvData;
            string[] unreadableCsv = { "NO_CSV" };
            string   pathToCsv     = "../../../CoSimplex_ABSW_53-tests.csv";

            FileAccessClass AccessFile = new FileAccessClass();

            csvData = AccessFile.ReadCsv(pathToCsv).Skip(1).ToArray(); //In addition to getting the CSV data,
                                                                       //it skips the 1st element of the array,
                                                                       //as that is not useful data.

            if (csvData[0] == unreadableCsv[0])
            {
                MessageBox.Show("No CSV found. Press OK to exit", "ERROR");
                Environment.Exit(404);
            }

            ParsingClass CsvParser = new ParsingClass();

            string[,] seperatedCsv = CsvParser.Parse(csvData);

            FormattingClass parsedCsvFormatter = new FormattingClass();

            string[,] humanReadableCsv = parsedCsvFormatter.Format(seperatedCsv);

            AccessFile.PrintToTxt(humanReadableCsv);
        }
        public void Seperate_a_real_line_copied_from_CSV_into_sections()
        {//Uses line copied from real CSV in format returned by File.ReadAllLines(string)
            string[] mockCsvData = { "1,VSTest: MonolithTests.NancyTests.RootModuleTests.when_unauthorized_get_on_root_url_should_redirect_us_to_login_page,OK,510" };

            ParsingClass Parser = new CSV_Formatter.ParsingClass();

            string[,] mockParsedCsvData = Parser.Parse(mockCsvData);

            string[,] expectedParsedCsvData = { { "1", "VSTest: MonolithTests.NancyTests.RootModuleTests.when_unauthorized_get_on_root_url_should_redirect_us_to_login_page", "OK", "510" } };
            CollectionAssert.AreEqual(expectedParsedCsvData, mockParsedCsvData);
        }
        public void Seperate_line_into_sections_with_simple_example_data()
        {
            string[] mockCsvData = { "1st_section,2nd_section,3rd_section,4th_section", "5th_section,6th_section,7th_section,8th_section" };

            ParsingClass Parser = new CSV_Formatter.ParsingClass();

            string[,] mockParsedCsvData = Parser.Parse(mockCsvData);

            string[,] expectedParsedCsvData = { { "1st_section", "2nd_section", "3rd_section", "4th_section" },
                                                { "5th_section", "6th_section", "7th_section", "8th_section" } };
            CollectionAssert.AreEqual(expectedParsedCsvData, mockParsedCsvData);
        }