From d82f751ca17758cb4c15521da0a91ab143e36f4a Mon Sep 17 00:00:00 2001 From: meld-cp <18450687+meld-cp@users.noreply.github.com> Date: Fri, 12 Jul 2024 15:41:02 +1200 Subject: [PATCH] Add another test for issue 507 --- tests/MiniExcelTests/MiniExcelIssueTests.cs | 40 +++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/tests/MiniExcelTests/MiniExcelIssueTests.cs b/tests/MiniExcelTests/MiniExcelIssueTests.cs index 1b25012d..ad5609c8 100644 --- a/tests/MiniExcelTests/MiniExcelIssueTests.cs +++ b/tests/MiniExcelTests/MiniExcelIssueTests.cs @@ -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 }, @@ -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(path, excelType: ExcelType.CSV, configuration: config).ToArray(); + + Assert.Equal(values.Length, getRowsInfo.Count()); + + } } } \ No newline at end of file