From 6f807612ffdac2ce58f76708a1c5592f0eb27590 Mon Sep 17 00:00:00 2001 From: Timothy Mothra Lee Date: Thu, 26 Mar 2020 14:00:29 -0700 Subject: [PATCH] cleanup --- .../ApplicationFolderProviderTest.cs | 24 ++++--------------- .../ApplicationFolderProvider.cs | 4 ---- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/BASE/Test/ServerTelemetryChannel.Test/TelemetryChannel.Tests/Implementation/ApplicationFolderProviderTest.cs b/BASE/Test/ServerTelemetryChannel.Test/TelemetryChannel.Tests/Implementation/ApplicationFolderProviderTest.cs index e1fda669b..dc9d7b20d 100644 --- a/BASE/Test/ServerTelemetryChannel.Test/TelemetryChannel.Tests/Implementation/ApplicationFolderProviderTest.cs +++ b/BASE/Test/ServerTelemetryChannel.Test/TelemetryChannel.Tests/Implementation/ApplicationFolderProviderTest.cs @@ -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); diff --git a/BASE/src/ServerTelemetryChannel/Implementation/ApplicationFolderProvider.cs b/BASE/src/ServerTelemetryChannel/Implementation/ApplicationFolderProvider.cs index 796c8b452..03ca2ad36 100644 --- a/BASE/src/ServerTelemetryChannel/Implementation/ApplicationFolderProvider.cs +++ b/BASE/src/ServerTelemetryChannel/Implementation/ApplicationFolderProvider.cs @@ -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; }