feat: Support newline configuration.

实装换行符配置项。
This commit is contained in:
real-zony 2021-05-17 21:06:15 +08:00
parent ed65790c43
commit 134d7eb5a0
2 changed files with 27 additions and 2 deletions

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}