Repository: dotnet/runtime
File: src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/EnumerableTests.cs (C#)

Code before:
            {
                string file = Path.Join(directory, GetTestFileName());
                File.Create(file).Dispose();
                expected.Add(file);
            }

            for (int i = 0; i < 100; i++) // test multiple times to ensure thread safety.
            {
                ConcurrentBag<string> result = [];
                ParallelLoopResult parallelResult = Parallel.ForEach(Directory.EnumerateFiles(directory), f => result.Add(f));
                AssertExtensions.CollectionEqual(expected, result, StringComparer.Ordinal);
            }
        }

        [Fact]
        [PlatformSpecific(TestPlatforms.Windows)]
        public void CreateSubdirectory_RootDriveSubfolder_Windows()
        {
            // Get the root of the OS drive (e.g., "C:\")
            string rootDrive = Path.GetPathRoot(Environment.SystemDirectory);

            // Create a DirectoryInfo for the root drive
            DirectoryInfo rootDirectory = new DirectoryInfo(rootDrive);

            // Create a unique test folder name to avoid conflicts
            string testFolderName = $"TestFolder_{Guid.NewGuid():N}";

            try
            {
                // Create a subdirectory directly in the root
                DirectoryInfo subDirectory = rootDirectory.CreateSubdirectory(testFolderName);

                // Verify it was created
                Assert.True(subDirectory.Exists);
                Assert.Equal(Path.Combine(rootDrive, testFolderName), subDirectory.FullName);
            }
            finally
            {
                // Cleanup
                string testFolderPath = Path.Combine(rootDrive, testFolderName);
                if (Directory.Exists(testFolderPath))
                {
                    Directory.Delete(testFolderPath, recursive: true);
                }
            }
        }

        [Fact]
        [PlatformSpecific(TestPlatforms.Linux)]
        public void CreateSubdirectory_RootDriveSubfolder_ThrowsUnauthorizedAccessException_Linux()
        {

Review comment (suggestion):
```suggestion
            string testFolderName = GetTestFileName();
```

Code after:
            {
                string file = Path.Join(directory, GetTestFileName());
                File.Create(file).Dispose();
                expected.Add(file);
            }

            for (int i = 0; i < 100; i++) // test multiple times to ensure thread safety.
            {
                ConcurrentBag<string> result = [];
                ParallelLoopResult parallelResult = Parallel.ForEach(Directory.EnumerateFiles(directory), f => result.Add(f));
                AssertExtensions.CollectionEqual(expected, result, StringComparer.Ordinal);
            }
        }

        [Fact]
        public void EnumerateDirectories_NonBreakingSpace()
        {
            DirectoryInfo rootDirectory = Directory.CreateDirectory(GetTestFilePath());
            DirectoryInfo subDirectory1 = rootDirectory.CreateSubdirectory("\u00A0");
            DirectoryInfo subDirectory2 = subDirectory1.CreateSubdirectory(GetTestFileName());

            FSAssert.EqualWhenOrdered(new string[] { subDirectory1.FullName, subDirectory2.FullName }, Directory.EnumerateDirectories(rootDirectory.FullName, string.Empty, SearchOption.AllDirectories));
        }

         [Fact]
         [PlatformSpecific(TestPlatforms.Windows)]
         public void EnumerateDirectories_TrailingDot()
         {
             string prefix = @"\\?\";
             string tempPath = GetTestFilePath();
             string fileName = "Test.txt";

             string[] dirPaths = {
                 Path.Join(prefix, tempPath, "Test"),
                 Path.Join(prefix, tempPath, "TestDot."),
                 Path.Join(prefix, tempPath, "TestDotDot..")
             };

             // Create directories and their files using "\\?\C:\" paths
             foreach (string dirPath in dirPaths)
             {
                 if (Directory.Exists(dirPath))
                 {
                     Directory.Delete(dirPath, recursive: true);
                 }

                 Directory.CreateDirectory(dirPath);

                 // Directory.Exists should work with directories containing trailing dots and prefixed with \\?\
                 Assert.True(Directory.Exists(dirPath));