Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions LINQtoCSV.Tests/CsvContextReadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,5 +367,55 @@ public void FileWithUnknownColumns_ShouldDiscardColumns() {
AssertRead(input, description, expected);

}


[TestMethod()]
public void GoodFileShouldReadRawData()
{
var description = new CsvFileDescription
{
SeparatorChar = ',',
FirstLineHasColumnNames = false
};

string input =
@"1,John,Doe,15,Washington
2,Jane,Doe,20,New York
";
var expected = new[]
{
new TestDataRow
{
new DataRowItem("1", 1),
new DataRowItem("John", 1),
new DataRowItem("Doe", 1),
new DataRowItem("15", 1),
new DataRowItem("Washington", 1)
},
new TestDataRow
{
new DataRowItem("2", 2),
new DataRowItem("Jane", 2),
new DataRowItem("Doe", 2),
new DataRowItem("20", 2),
new DataRowItem("New York", 2)
}
};

AssertRead(input, description, expected);

}

public class TestDataRow : List<DataRowItem>, IDataRow, IAssertable<TestDataRow>
{
public void AssertEqual(TestDataRow other)
{
for (var i = 0; i < this.Count; i++)
{
Assert.AreEqual(other[i].Value, this[i].Value);
Assert.AreEqual(other[i].LineNbr, this[i].LineNbr);
}
}
}
}
}
8 changes: 7 additions & 1 deletion LINQtoCSV/CsvContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,13 @@ private IEnumerable<T> ReadData<T>(
{
if (readingRawDataRows)
{
obj = row as T;
var newRow = new T() as IDataRow;
for (var i = 0; i < row.Count; i++)
{
newRow.Add(row[i]);
}

obj = newRow as T;
}
else
{
Expand Down