Exemple #1
0
        public async Task TestUseValue()
        {
            var csvData =
                "A;B;C" + Environment.NewLine +
                "a1;b1;c1" + Environment.NewLine +
                "a2;b2;c2";

            using var csvReader = new CsvReader(csvData);

            var csvTableReader = new CsvTableReader(csvReader);

            Assert.NotNull(csvTableReader);

            await csvTableReader.ReadHeadersAsync();

            await csvTableReader.ReadAsync();

            csvTableReader.UseValue(0, s => Assert.Equal("a1", s));
            csvTableReader.UseValue(1, s => Assert.Equal("b1", s));
            csvTableReader.UseValue(2, s => Assert.Equal("c1", s));

            await csvTableReader.ReadAsync();

            csvTableReader.UseValue("A", s => Assert.Equal("a2", s));
            csvTableReader.UseValue("B", s => Assert.Equal("b2", s));
            csvTableReader.UseValue("C", s => Assert.Equal("c2", s));
        }