Exemplo n.º 1
0
        public void ParseWithNULLStringTest()
        {
            CsvParserOptions   csvParserOptions = new CsvParserOptions(false, ';');
            CsvReaderOptions   csvReaderOptions = new CsvReaderOptions(new[] { Environment.NewLine });
            CsvEntityMapping   csvMapper        = new CsvEntityMapping();
            CsvParser <Entity> csvParser        = new CsvParser <Entity>(csvParserOptions, csvMapper);

            var stringBuilder = new StringBuilder()
                                .AppendLine("123,456");

            var result = csvParser
                         .ReadFromString(csvReaderOptions, stringBuilder.ToString())
                         .ToList();

            Assert.AreEqual(123.456, result[0].Result.Value);
        }
Exemplo n.º 2
0
        public void ParseWithNULLStringTest()
        {
            CsvParserOptions   csvParserOptions = new CsvParserOptions(false, ';');
            CsvReaderOptions   csvReaderOptions = new CsvReaderOptions(new[] { Environment.NewLine });
            CsvEntityMapping   csvMapper        = new CsvEntityMapping();
            CsvParser <Entity> csvParser        = new CsvParser <Entity>(csvParserOptions, csvMapper);

            var stringBuilder = new StringBuilder()
                                .AppendLine("NULL")
                                .AppendLine("1.0")
                                .AppendLine("NULL")
                                .AppendLine("2.0");

            var result = csvParser
                         .ReadFromString(csvReaderOptions, stringBuilder.ToString())
                         .ToList();

            Assert.AreEqual(null, result[0].Result.Property);
            Assert.AreEqual(1.0, result[1].Result.Property, 1e-5);
            Assert.AreEqual(null, result[2].Result.Property);
            Assert.AreEqual(2.0, result[3].Result.Property, 1e-5);
        }