public void TestGetRecordsGeneric() { using (var stream = new MemoryStream()) using (var writer = new StreamWriter(stream)) using (var reader = new StreamReader(stream)) using (var dtReader = new DelimitedTextReader(reader)) { writer.Write("Field1,Field2,Field3,Field4,Field5\r\n"); writer.Write("value1,100,true,\"12/31/2016\", 25.76\r\n"); writer.Write("value2,200,false,\"1/1/2016\", 67.52\r\n"); writer.Flush(); stream.Position = 0; dtReader.FirstRowIsHeader = true; var records = dtReader.GetAllRecords <TestRecord>().ToList(); Assert.Equal(2, records.Count); TestRecord trecord = records[0]; Assert.NotNull(trecord); Assert.Equal("value1", trecord.Field1); Assert.Equal(100, trecord.Field2); Assert.True(trecord.Field3); Assert.Equal(DateTime.Parse("12/31/2016").ToShortDateString(), trecord.Field4.ToShortDateString()); Assert.Equal(25.76M, trecord.Field5); trecord = records[1]; Assert.NotNull(trecord); Assert.Equal("value2", trecord.Field1); Assert.Equal(200, trecord.Field2); Assert.False(trecord.Field3); Assert.Equal(DateTime.Parse("1/1/2016").ToShortDateString(), trecord.Field4.ToShortDateString()); Assert.Equal(67.52M, trecord.Field5); } }