public void GetValuesTest() { var s = new StringBuilder(); s.AppendLine("Boolean,Byte,Bytes,Char,Chars,DateTime,Decimal,Double,Float,Guid,Short,Int,Long,Null"); s.AppendLine("true,1,0x0102,a,ab,1/1/2019,1.23,4.56,7.89,eca0c8c6-9a2a-4e6c-8599-3561abda13f1,1,2,3,null"); using (var reader = new StringReader(s.ToString())) using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture)) { csv.Context.TypeConverterOptionsCache.GetOptions <string>().NullValues.Add("null"); var dataReader = new CsvDataReader(csv); dataReader.Read(); Assert.True(dataReader.GetBoolean(0)); Assert.Equal(1, dataReader.GetByte(1)); byte[] byteBuffer = new byte[2]; dataReader.GetBytes(2, 0, byteBuffer, 0, byteBuffer.Length); Assert.Equal(0x1, byteBuffer[0]); Assert.Equal(0x2, byteBuffer[1]); Assert.Equal('a', dataReader.GetChar(3)); char[] charBuffer = new char[2]; dataReader.GetChars(4, 0, charBuffer, 0, charBuffer.Length); Assert.Equal('a', charBuffer[0]); Assert.Equal('b', charBuffer[1]); Assert.Null(dataReader.GetData(0)); Assert.Equal(DateTime.Parse("1/1/2019"), dataReader.GetDateTime(5)); Assert.Equal(typeof(string).Name, dataReader.GetDataTypeName(0)); Assert.Equal(1.23m, dataReader.GetDecimal(6)); Assert.Equal(4.56d, dataReader.GetDouble(7)); Assert.Equal(typeof(string), dataReader.GetFieldType(0)); Assert.Equal(7.89f, dataReader.GetFloat(8)); Assert.Equal(Guid.Parse("eca0c8c6-9a2a-4e6c-8599-3561abda13f1"), dataReader.GetGuid(9)); Assert.Equal(1, dataReader.GetInt16(10)); Assert.Equal(2, dataReader.GetInt32(11)); Assert.Equal(3, dataReader.GetInt64(12)); Assert.Equal("Boolean", dataReader.GetName(0)); Assert.Equal(0, dataReader.GetOrdinal("Boolean")); Assert.Equal("true", dataReader.GetString(0)); Assert.Equal("true", dataReader.GetValue(0)); var objectBuffer = new object[14]; dataReader.GetValues(objectBuffer); Assert.Equal("true", objectBuffer[0]); Assert.Equal(DBNull.Value, objectBuffer[13]); Assert.True(dataReader.IsDBNull(13)); } }