Skip to content

Commit

Permalink
Add another test for issue 507
Browse files Browse the repository at this point in the history
  • Loading branch information
meld-cp committed Jul 12, 2024
1 parent 43a5287 commit d82f751
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions tests/MiniExcelTests/MiniExcelIssueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3536,13 +3536,18 @@ class Issue507V01
public int D { get; set; }
}

class Issue507V02 {
public DateTime B { get; set; }
public int D { get; set; }
}

[Fact]
public void Issue507()
public void Issue507_1()
{
//Problem with multi-line when using Query func
//https://github.com/mini-software/MiniExcel/issues/507

var path = Path.Combine(Path.GetTempPath(), string.Concat( nameof(MiniExcelIssueTests),"_", nameof(Issue507), ".csv" ));
var path = Path.Combine(Path.GetTempPath(), string.Concat( nameof(MiniExcelIssueTests),"_", nameof(Issue507_1), ".csv" ));
var values = new Issue507V01[]
{
new() { A = "Github", B = DateTime.Parse("2021-01-01"), C = "abcd", D = 123 },
Expand Down Expand Up @@ -3579,5 +3584,36 @@ public void Issue507()
Assert.Equal(@$"Microsoft"""" {config.NewLine}Test{config.NewLine}3", getRowsInfo[3].A);
Assert.Equal(@$"a""""{config.NewLine}b{config.NewLine}{config.NewLine}c", getRowsInfo[3].C);
}

[Fact]
public void Issue507_2() {
//Problem with multi-line when using Query func
//https://github.com/mini-software/MiniExcel/issues/507

var path = Path.Combine(Path.GetTempPath(), string.Concat(nameof(MiniExcelIssueTests), "_", nameof(Issue507_2), ".csv"));
var values = new Issue507V02[]
{
new() { B = DateTime.Parse("2021-01-01"), D = 123 },
new() { B = DateTime.Parse("2021-02-01"), D = 123 },
new() { B = DateTime.Parse("2021-02-01"), D = 123 },
new() { B = DateTime.Parse("2021-02-01"), D = 123 },
};

var config = new CsvConfiguration() {
//AlwaysQuote = true,
ReadLineBreaksWithinQuotes = true,
};

// create
using (var stream = File.Create(path)) {
stream.SaveAs(values, excelType: ExcelType.CSV, configuration: config);
}

// read
var getRowsInfo = MiniExcel.Query<Issue507V02>(path, excelType: ExcelType.CSV, configuration: config).ToArray();

Assert.Equal(values.Length, getRowsInfo.Count());

}
}
}

0 comments on commit d82f751

Please sign in to comment.