Update tests for unicode chars

This commit is contained in:
Michael Bucari-Tovo 2022-06-19 17:59:16 -06:00
parent 733ca891de
commit 8374fea776
2 changed files with 8 additions and 8 deletions

View File

@ -20,7 +20,7 @@ namespace FileNamingTemplateTests
var longText = sb.ToString();
var expectedOld = "C:\\foo\\bar\\my_ book 00000000000000000000000000000000000000000 [ID123456].txt";
var expectedNew = "C:\\foo\\bar\\my_ book 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 [ID123456].txt";
var expectedNew = "C:\\foo\\bar\\my book 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 [ID123456].txt";
var f1 = OLD_GetValidFilename(@"C:\foo\bar", "my: book " + longText, "txt", "ID123456");
var f2 = NEW_GetValidFilename_FileNamingTemplate(@"C:\foo\bar", "my: book " + longText, "txt", "ID123456");

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -17,25 +17,25 @@ namespace FileUtilityTests
// needs separate method. middle null param not running correctly in TestExplorer when used in DataRow()
[TestMethod]
[DataRow("http://test.com/a/b/c", @"http\test.com\a\b\c")]
[DataRow("http://test.com/a/b/c", @"http\test.com\a\b\c")]
public void null_replacement(string inStr, string outStr) => Tests(inStr, null, outStr);
[TestMethod]
// empty replacement
[DataRow("abc*abc.txt", "", "abcabc.txt")]
[DataRow("abc*abc.txt", "", "abcabc.txt")]
// non-empty replacement
[DataRow("abc*abc.txt", "ZZZ", "abcZZZabc.txt")]
[DataRow("abc*abc.txt", "ZZZ", "abcabc.txt")]
// standardize slashes
[DataRow(@"a/b\c/d", "Z", @"a\b\c\d")]
// remove illegal chars
[DataRow("a*?:z.txt", "Z", "aZZZz.txt")]
[DataRow("a*?:z.txt", "Z", "az.txt")]
// retain drive letter path colon
[DataRow(@"C:\az.txt", "Z", @"C:\az.txt")]
// replace all other colons
[DataRow(@"a\b:c\d.txt", "ZZZ", @"a\bZZZc\d.txt")]
[DataRow(@"a\b:c\d.txt", "ZZZ", @"a\bc\d.txt")]
// remove empty directories
[DataRow(@"C:\a\\\b\c\\\d.txt", "ZZZ", @"C:\a\b\c\d.txt")]
[DataRow(@"C:\""foo\<id>", "ZZZ", @"C:\ZZZfoo\ZZZidZZZ")]
[DataRow(@"C:\""foo\<id>", "ZZZ", @"C:\“foo\id")]
public void Tests(string inStr, string replacement, string outStr) => Assert.AreEqual(outStr, FileUtility.GetSafePath(inStr, replacement).PathWithoutPrefix);
}