public void MatchOnHeader() { var localSubject = new CsvService <CsvTestObject>(); using (var writer = new StreamWriter(new MemoryStream())) { //Assemble writer.WriteLine( "FirstName,LastName,Quantity,DateOfBirth"); writer.WriteLine("Test, User, 1, 2018-1-1"); writer.WriteLine("Second Test, Second User, 2, 2018-2-1"); writer.WriteLine("Third Test, Third User, 3, 2018-3-1"); writer.Flush(); writer.BaseStream.Position = 0; //Act var records = localSubject.GetRecords(writer.BaseStream, null); //Assert Assert.Equal(3, records.Count); Assert.Equal("Test", records[0].FirstName); Assert.Equal("User", records[0].LastName); Assert.Equal(1, records[0].Quantity); Assert.Equal(new DateTime(2018, 1, 1), records[0].DateOfBirth); Assert.Equal("Second Test", records[1].FirstName); Assert.Equal("Second User", records[1].LastName); Assert.Equal(2, records[1].Quantity); Assert.Equal(new DateTime(2018, 2, 1), records[1].DateOfBirth); Assert.Equal("Third Test", records[2].FirstName); Assert.Equal("Third User", records[2].LastName); Assert.Equal(3, records[2].Quantity); Assert.Equal(new DateTime(2018, 3, 1), records[2].DateOfBirth); } }