From da845555519c15a61e6610beaf9849f8a08415fe Mon Sep 17 00:00:00 2001 From: Richard Deeming Date: Fri, 22 Dec 2023 12:25:06 +0000 Subject: [PATCH] Environment.NewLine causing test failures on Linux. --- RecordParser.Test/FileReaderTest.cs | 6 +++--- RecordParser.Test/QuotedFileReaderTest.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/RecordParser.Test/FileReaderTest.cs b/RecordParser.Test/FileReaderTest.cs index 77da323..4b5c290 100644 --- a/RecordParser.Test/FileReaderTest.cs +++ b/RecordParser.Test/FileReaderTest.cs @@ -246,7 +246,7 @@ public void Read_csv_file_all_fields_quoted(string fileContent, bool hasHeader, new () { id = new Guid("63858071-cbb3-5abd-9f88-3dfd565cc4ab"), name = "Lucy Berry", age = 49, birthday = DateTime.Parse("11/12/1961"), gender = Gender.Female, email = "vanvo@ro.pk", children = false }, new () { id = new Guid("203804f9-93e7-5510-8bb2-177296bafe6a"), name = "Frank Fox", age = 36, birthday = DateTime.Parse("3/19/1977"), gender = Gender.Male, email = "vav@ped.fj", children = true }, new () { id = new Guid("a8af66fb-bad4-51eb-810c-bf3ca22337c6"), name = "Isabel Todd", age = 51, birthday = DateTime.Parse("9/16/1999"), gender = Gender.Female, email = "gu@or.bz", children = false }, - new () { id = new Guid("1a3d8a66-3e0c-50eb-99c1-a3926bce15ed"), name = $"Joseph {Environment.NewLine}Scott", age = 55, birthday = DateTime.Parse("10/26/1986"), gender = Gender.Male, email = "bup@vugeb.tt", children = false }, + new () { id = new Guid("1a3d8a66-3e0c-50eb-99c1-a3926bce15ed"), name = "Joseph \r\nScott", age = 55, birthday = DateTime.Parse("10/26/1986"), gender = Gender.Male, email = "bup@vugeb.tt", children = false }, new () { id = new Guid("aa7d4395-f10f-5776-9912-e3d86c4b9d3c"), name = "Gilbert Brooks", age = 56, birthday = DateTime.Parse("3/1/1956"), gender = Gender.Female, email = "epiju@ba.ly", children = true }, new () { id = new Guid("1d25b811-4002-5744-ac40-93a50f2a442c"), name = "Louis \"Ronaldo\" Bennett", age = 25, birthday = DateTime.Parse("4/4/1967"), gender = Gender.Male, email = "ma@itrovive.tv", children = true }, new () { id = new Guid("8e963ae5-a9ed-5572-b11c-566abc6a8a56"), name = "Norman Parker", age = 57, birthday = DateTime.Parse("4/17/1969"), gender = Gender.Male, email = "omi@hewepa.bw", children = true }, @@ -291,7 +291,7 @@ public void Read_quoted_csv_file(string fileContent, bool hasHeader, bool parall var expectedItems = new Quoted[] { new Quoted { Id = 1, Date = new DateTime(2010, 01, 02), Name = "Ana", Rate = "Good", Ranking = 56 }, - new Quoted { Id = 2, Date = new DateTime(2011, 05, 12), Name = "Bob", Rate = $"Much {Environment.NewLine}Good", Ranking = 4 }, + new Quoted { Id = 2, Date = new DateTime(2011, 05, 12), Name = "Bob", Rate = "Much \r\nGood", Ranking = 4 }, new Quoted { Id = 3, Date = new DateTime(2013, 12, 10), Name = "Carla", Rate = "\"Medium\"", Ranking = 5 }, new Quoted { Id = 4, Date = new DateTime(2015, 03, 03), Name = "Derik", Rate = "Absolute, Awesome", Ranking = 1 }, } @@ -569,4 +569,4 @@ public void Read_plain_text_of_fixed_length_file(string fileContent, bool parall result.Should().BeEquivalentTo(expected, cfg => cfg.WithStrictOrdering()); } } -} \ No newline at end of file +} diff --git a/RecordParser.Test/QuotedFileReaderTest.cs b/RecordParser.Test/QuotedFileReaderTest.cs index 007b981..16a81f6 100644 --- a/RecordParser.Test/QuotedFileReaderTest.cs +++ b/RecordParser.Test/QuotedFileReaderTest.cs @@ -52,7 +52,7 @@ public void Given_quoted_field_in_any_column_should_parse_successfully(bool para a,1 ", 3,b , "4" a,b,c,d - """.Replace(Environment.NewLine, newline); + """.Replace("\r\n", newline); var expected = new[] { @@ -119,7 +119,7 @@ public void Given_quoted_field_in_first_column_should_parse_successfully(bool pa y",2,3,4 """; - var expected = ($"x{Environment.NewLine}y","2","3","4"); + var expected = ("x\r\ny","2","3","4"); var reader = new StringReader(fileContent); var options = new VariableLengthReaderRawOptions { @@ -375,4 +375,4 @@ public void Read_csv_file_with_quoted_quote(bool parallel) items.Should().BeEquivalentTo(expectedItems, cfg => cfg.WithStrictOrdering()); } } -} \ No newline at end of file +}