示例#1
0
        public void ParseLine_InvalidDateTimeFormat_Exception()
        {
            CsvLineParser lineParser  = new CsvLineParser(TestInitializationFactory.GenerateFakeColumnTypes());
            string        lineToParse = "2018ax01-03 12:00:00, 1,2,3,4,5";

            Assert.Catch(() => lineParser.ParseLine(lineToParse));
        }
示例#2
0
        public void LoadAll_SimpleFileLoad_Success()
        {
            CsvImporter importer = new CsvImporter(relativePath, TestInitializationFactory.GenerateFakeColumnTypes());
            var         result   = importer.LoadAll();
            int         numItems = EnumerateTestAndCount(result);

            // Test that All items have been read
            Assert.AreEqual(numItems, 7);
        }
示例#3
0
        public void LoadNext_LoadLast3Lines_Success()
        {
            CsvImporter importer = new CsvImporter(relativePath, TestInitializationFactory.GenerateFakeColumnTypes());
            bool        endOfFile;
            var         result   = importer.LoadRange(3, out endOfFile, 4);
            int         numItems = EnumerateTestAndCount(result);

            // Test that All items have been read
            Assert.AreEqual(numItems, 3);
            Assert.AreEqual(endOfFile, true);
        }
示例#4
0
        public void ParseLine_ValidLineParse_Success()
        {
            CsvLineParser lineParser  = new CsvLineParser(TestInitializationFactory.GenerateFakeColumnTypes());
            string        lineToParse = "2018-01-03 12:00:00, 1,2,3,4,5";
            DataObject    result      = lineParser.ParseLine(lineToParse);

            Assert.AreEqual(result.Columns.Length, 6);
            Assert.AreEqual(result.Columns[0].GetType(), typeof(DateTime));
            for (int i = 1; i < 6; i++)
            {
                Assert.AreEqual(result.Columns[i].GetType(), typeof(int));
                Assert.AreEqual(result.Columns[i], i);
            }
        }