Remove multispace instances from template filenames (#637)
This commit is contained in:
parent
ac87d70613
commit
1b09b1fd48
2 changed files with 83 additions and 0 deletions
|
|
@ -107,6 +107,42 @@ namespace TemplatesTests
|
|||
.Should().Be(expected);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("<samplerate>", "", "", "100")]
|
||||
[DataRow(" <samplerate> ", "", "", "100")]
|
||||
[DataRow("4<samplerate>4", "", "", "100")]
|
||||
[DataRow("<bitrate> - <bitrate>", "", "", "1 8 - 1 8")]
|
||||
[DataRow("<bitrate> 42 <bitrate>", "", "", "1 8 1 8")]
|
||||
[DataRow(" <bitrate> - <bitrate> ", "", "", "1 8 - 1 8")]
|
||||
[DataRow("4<bitrate> - <bitrate> 4", "", "", "1 8 - 1 8")]
|
||||
[DataRow("4<bitrate> - <bitrate> 4", "", "", "1 8 - 1 8")]
|
||||
[DataRow("<channels><channels><samplerate><channels><channels>", "", "", "100")]
|
||||
[DataRow(" <channels> <channels> <samplerate> <channels> <channels>", "", "", "100")]
|
||||
[DataRow(" <channels> - <channels> <samplerate> <channels> - <channels>", "", "", "- 100 -")]
|
||||
|
||||
public void Tests_removeSpaces(string template, string dirFullPath, string extension, string expected)
|
||||
{
|
||||
if (Environment.OSVersion.Platform is not PlatformID.Win32NT)
|
||||
{
|
||||
dirFullPath = dirFullPath.Replace("C:", "").Replace('\\', '/');
|
||||
expected = expected.Replace("C:", "").Replace('\\', '/');
|
||||
}
|
||||
var replacements
|
||||
= new ReplacementCharacters
|
||||
{
|
||||
Replacements = Replacements.Replacements
|
||||
.Append(new Replacement('4', " ", ""))
|
||||
.Append(new Replacement('2', " ", ""))
|
||||
.ToArray() };
|
||||
|
||||
Templates.TryGetTemplate<Templates.FileTemplate>(template, out var fileTemplate).Should().BeTrue();
|
||||
|
||||
fileTemplate
|
||||
.GetFilename(GetLibraryBook(), dirFullPath, extension, replacements)
|
||||
.PathWithoutPrefix
|
||||
.Should().Be(expected);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("<bitrate>Kbps <samplerate>Hz", "128Kbps 44100Hz")]
|
||||
[DataRow("<bitrate>Kbps <samplerate[6]>Hz", "128Kbps 044100Hz")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue