Esempio n. 1
0
        public void RunTest()
        {
            var options = new CsvParserOptions(false, new StringSplitTokenizer(new[] { ',' }, false));
            var mapping = new TestModelMapping();
            var parser  = new CsvParser <TestModel>(options, mapping);

            var testFilePath = GetTestFilePath();

            MeasurementUtils.MeasureElapsedTime("Reading 100 000 Lines", () =>
            {
                var lines = parser
                            .ReadFromFile(testFilePath, Encoding.UTF8)
                            .Where(x => x.IsValid)
                            .Count();

                Assert.AreEqual(100000, lines);
            });
        }
Esempio n. 2
0
        public void RunRfc4180TokenizerTest()
        {
            var options = new CsvParserOptions(false, new RFC4180Tokenizer(new Options('"', '\\', ',')));
            var mapping = new TestModelMapping();
            var parser  = new CsvParser <TestModel>(options, mapping);

            string filename = GetTestFilePath();

            MeasurementUtils.MeasureElapsedTime(
                description: $"Reading {filename} ...",
                action: () =>
            {
                var cnt = parser
                          .ReadFromFile(filename, Encoding.UTF8)
                          .Where(x => x.IsValid)
                          .Count();

                TestContext.WriteLine($"Parsed {cnt} valid lines ...");
            },
                timespanFormatter: x => $"{x.TotalMilliseconds} Milliseconds");
        }