Audit culture bugs (#7707)

* Added comments and fixed CultureInfo /  StringComparison where appropriate

* Addressed comments

* Fixed comment
This commit is contained in:
Avneet Kaur
2020-10-30 16:43:09 -07:00
committed by GitHub
parent bd34127cd4
commit 2c5b9b4d52
54 changed files with 160 additions and 28 deletions

View File

@@ -69,8 +69,10 @@ namespace Microsoft.Plugin.Folder.UnitTests
{
// Setup
var folderHelperMock = new Mock<IFolderHelper>();
// Using Ordinal since this is used with paths
folderHelperMock.Setup(r => r.IsDriveOrSharedFolder(It.IsAny<string>()))
.Returns<string>(s => s.StartsWith("C:", StringComparison.CurrentCultureIgnoreCase));
.Returns<string>(s => s.StartsWith("C:", StringComparison.Ordinal));
var itemResultMock = new Mock<IItemResult>();

View File

@@ -73,15 +73,17 @@ namespace Microsoft.Plugin.Folder.UnitTests
switch (isRecursive)
{
case false:
folderSearchFunc = s => s.Equals(search, StringComparison.CurrentCultureIgnoreCase);
// Using Ordinal since this is internal
folderSearchFunc = s => s.Equals(search, StringComparison.Ordinal);
var regexSearch = TrimDirectoryEnd(search);
fileSearchFunc = s => Regex.IsMatch(s, $"^{Regex.Escape(regexSearch)}[^\\\\]*$");
break;
case true:
folderSearchFunc = s => s.StartsWith(search, StringComparison.CurrentCultureIgnoreCase);
fileSearchFunc = s => s.StartsWith(search, StringComparison.CurrentCultureIgnoreCase);
// Using Ordinal since this is internal
folderSearchFunc = s => s.StartsWith(search, StringComparison.Ordinal);
fileSearchFunc = s => s.StartsWith(search, StringComparison.Ordinal);
break;
}