Skip to content

Commit

Permalink
add test for basic cenario
Browse files Browse the repository at this point in the history
  • Loading branch information
leandromoh committed Nov 12, 2023
1 parent 047a016 commit ee7c202
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions RecordParser.Test/QuotedFileReaderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,55 @@ public void Given_quoted_field_in_any_column_should_parse_successfully(bool para
records.Should().BeEquivalentTo(expected, cfg => cfg.WithStrictOrdering());
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public void Given_quoted_field_in_first_column_should_parse_successfully(bool parallel)
{
// Arrange

var fileContent = $"""
A,B,C,D
"x
y",2,3,4
""";

var expected = ($"x{Environment.NewLine}y","2","3","4");
var reader = new StringReader(fileContent);
var options = new VariableLengthReaderRawOptions
{
HasHeader = true,
ContainsQuotedFields = true,
ColumnCount = 4,
Separator = ",",
ParallelismOptions = new()
{
Enabled = parallel,
MaxDegreeOfParallelism = 2,
},
};

// Act

var result = reader.ReadRecordsRaw(options, getField =>
{
var record =
(
getField(0),
getField(1),
getField(2),
getField(3)
);
return record;
}).ToList();

// Assert

result.Should().HaveCount(1);
var row = result[0];
row.Should().Be(expected);
}

[Theory]
[InlineData(true)]
[InlineData(false)]
Expand Down

0 comments on commit ee7c202

Please sign in to comment.