From 134d7eb5a064a51e3c37610e609a89bbd1a80a7f Mon Sep 17 00:00:00 2001 From: real-zony Date: Mon, 17 May 2021 21:06:15 +0800 Subject: [PATCH] feat: Support newline configuration. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 实装换行符配置项。 --- .../Lyric/LyricItemCollection.cs | 4 +-- .../Lyric/LyricCollectionTests.cs | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 tests/ZonyLrcTools.Tests/Infrastructure/Lyric/LyricCollectionTests.cs diff --git a/src/ZonyLrcTools.Cli/Infrastructure/Lyric/LyricItemCollection.cs b/src/ZonyLrcTools.Cli/Infrastructure/Lyric/LyricItemCollection.cs index a68f342..f604dab 100644 --- a/src/ZonyLrcTools.Cli/Infrastructure/Lyric/LyricItemCollection.cs +++ b/src/ZonyLrcTools.Cli/Infrastructure/Lyric/LyricItemCollection.cs @@ -104,8 +104,8 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric public override string ToString() { var lyricBuilder = new StringBuilder(); - ForEach(lyric => lyricBuilder.Append(lyric).Append("\r\n")); - return lyricBuilder.ToString().TrimEnd("\r\n"); + ForEach(lyric => lyricBuilder.Append(lyric).Append(Option.LineBreak)); + return lyricBuilder.ToString().TrimEnd(Option.LineBreak); } } } \ No newline at end of file diff --git a/tests/ZonyLrcTools.Tests/Infrastructure/Lyric/LyricCollectionTests.cs b/tests/ZonyLrcTools.Tests/Infrastructure/Lyric/LyricCollectionTests.cs new file mode 100644 index 0000000..19a3c10 --- /dev/null +++ b/tests/ZonyLrcTools.Tests/Infrastructure/Lyric/LyricCollectionTests.cs @@ -0,0 +1,25 @@ +using Shouldly; +using Xunit; +using ZonyLrcTools.Cli.Infrastructure.Lyric; + +namespace ZonyLrcTools.Tests.Infrastructure.Lyric +{ + public class LyricCollectionTests : TestBase + { + [Fact] + public void LyricCollectionLineBreak_Test() + { + var lyricObject = new LyricItemCollection(new LyricItemCollectionOption + { + IsOneLine = false, + LineBreak = LineBreakType.MacOs + }) + { + new(0, 20, "你好世界!"), + new(0, 22, "Hello World!") + }; + + lyricObject.ToString().ShouldContain(LineBreakType.MacOs); + } + } +} \ No newline at end of file