This commit is contained in:
Timothy Mothra Lee 2020-03-26 14:00:29 -07:00
Родитель 3e3f69caf5
Коммит 6f807612ff
2 изменённых файлов: 4 добавлений и 24 удалений

Просмотреть файл

@ -155,19 +155,13 @@
[TestCategory("WindowsOnly")]
public void GetApplicationFolderReturnsSubfolderFromTempFolderIfLocalAppDataIsTooLong()
{
string longDirectoryName = Path.Combine(this.testDirectory.FullName, new string('A', 500)); //Windows has a max directory length of 248 characters.
// For reasons i don't understand, DotNetCore is able to create longer directory names. I've increased the length of this test path to guarantee that it fails.
string longDirectoryName = Path.Combine(this.testDirectory.FullName, new string('A', 300)); //Windows has a max directory length of 248 characters.
DirectoryInfo temp = this.CreateTestDirectory("Temp");
//TODO PRINT FULL FOLDER PATHS
//System.Console.WriteLine($"LocalAppData: {localAppData.FullName}");
System.Console.WriteLine($"LocalAppData: {longDirectoryName}");
System.Console.WriteLine($"Temp: {temp.FullName}");
// Initialize ApplicationfolderProvider
var environmentVariables = new Hashtable
{
//{ "LOCALAPPDATA", localAppData.FullName },
{ "LOCALAPPDATA", longDirectoryName },
{ "TEMP", temp.FullName },
};
@ -176,12 +170,10 @@
// Evaluate
Assert.IsNotNull(applicationFolder);
Assert.IsFalse(Directory.Exists(longDirectoryName));
Assert.IsTrue(Directory.Exists(temp.FullName));
//Assert.AreEqual(0, localAppData.GetDirectories().Length, "TEST ERROR: localAppData subdirectories were not expected.");
Assert.IsFalse(Directory.Exists(longDirectoryName), "TEST ERROR: This directory should not be created.");
Assert.IsTrue(Directory.Exists(temp.FullName), "TEST ERROR: This directory should be created.");
Assert.AreEqual(1, temp.GetDirectories().Length, "TEST FAIL: TEMP subdirectories were not created");
//localAppData.Delete(true);
temp.Delete(true);
}
@ -329,15 +321,7 @@
private DirectoryInfo CreateTestDirectory(string path, FileSystemRights rights = FileSystemRights.FullControl, AccessControlType access = AccessControlType.Allow)
{
var testPath = Path.Combine(this.testDirectory.FullName, path);
if (Directory.Exists(testPath))
{
Directory.Delete(testPath);
}
DirectoryInfo directory = this.testDirectory.CreateSubdirectory(path);
Assert.IsTrue(Directory.Exists(directory.FullName), $"failed to create test directory: {directory.FullName}");
DirectorySecurity security = directory.GetAccessControl();
security.AddAccessRule(new FileSystemAccessRule(WindowsIdentity.GetCurrent().Name, rights, access));
directory.SetAccessControl(security);

Просмотреть файл

@ -62,7 +62,6 @@
object localAppData = this.environment["LOCALAPPDATA"];
if (localAppData != null)
{
System.Console.WriteLine("Attempt to create localAppData directory...");
result = this.CreateAndValidateApplicationFolder(localAppData.ToString(), createSubFolder: true, errors: errors);
}
}
@ -72,14 +71,12 @@
object temp = this.environment["TEMP"];
if (temp != null)
{
System.Console.WriteLine("Attempt to create TEMP directory...");
result = this.CreateAndValidateApplicationFolder(temp.ToString(), createSubFolder: true, errors: errors);
}
}
if (result == null)
{
System.Console.WriteLine("ApplicationfolderProvider unable to create directories.");
TelemetryChannelEventSource.Log.TransmissionStorageAccessDeniedError(string.Join(Environment.NewLine, errors), this.identityProvider.GetName(), this.customFolderName);
}
@ -97,7 +94,6 @@
private static string GetPathAccessFailureErrorMessage(Exception exp, string path)
{
System.Console.WriteLine("Error {0} {1}", exp.ToString(), path);
return "Path: " + path + "; Error: " + exp.Message + Environment.NewLine;
}