示例#1
0
 [PlatformSpecific(PlatformID.Windows)] // Unix equivalent tested already in CreateDirectory
 public void WindowsWhiteSpaceAsPath_ReturnsFalse()
 {
     // Checks that errors aren't thrown when calling Exists() on impossible paths
     Assert.All(IOInputs.GetWhiteSpace(), (component) =>
     {
         Assert.False(Exists(component));
     });
 }
示例#2
0
        public void WindowsWhiteSpaceAsPath_ThrowsArgumentException()
        {
            var paths = IOInputs.GetWhiteSpace();

            Assert.All(paths, (path) =>
            {
                Assert.Throws <ArgumentException>(() => Create(path));
            });
        }
示例#3
0
        public void WindowsWhitespacePath()
        {
            FileInfo testFile = new FileInfo(GetTestFilePath());

            Assert.All(IOInputs.GetWhiteSpace(), (whitespace) =>
            {
                Assert.Throws <ArgumentException>(() => Move(testFile.FullName, whitespace));
            });
        }
示例#4
0
        public void UnixWhiteSpaceAsPath_Allowed()
        {
            var paths = IOInputs.GetWhiteSpace();

            Assert.All(paths, (path) =>
            {
                Create(Path.Combine(TestDirectory, path));
                Assert.True(Directory.Exists(Path.Combine(TestDirectory, path)));
            });
        }
示例#5
0
        [PlatformSpecific(PlatformID.Windows)] // In Windows, trailing whitespace in a path is trimmed
        public void TrimTrailingWhitespacePath()
        {
            FileInfo testFile = new FileInfo(GetTestFilePath());

            testFile.Create().Dispose();
            Assert.All((IOInputs.GetWhiteSpace()), (component) =>
            {
                Assert.True(Exists(testFile.FullName + component)); // string concat in case Path.Combine() trims whitespace before Exists gets to it
            });
        }
示例#6
0
        public void UnixWhitespacePath()
        {
            FileInfo testFileSource = new FileInfo(GetTestFilePath());

            testFileSource.Create().Dispose();
            Assert.All(IOInputs.GetWhiteSpace(), (whitespace) =>
            {
                Move(testFileSource.FullName, Path.Combine(TestDirectory, whitespace));
                Move(Path.Combine(TestDirectory, whitespace), testFileSource.FullName);
            });
        }
示例#7
0
        public void UnixNonSignificantTrailingWhiteSpace()
        {
            // Unix treats trailing/prename whitespace as significant and a part of the name.
            DirectoryInfo testDir    = Create(GetTestFilePath());
            var           components = IOInputs.GetWhiteSpace();

            Assert.All(components, (component) =>
            {
                string path          = IOServices.RemoveTrailingSlash(testDir.FullName) + component;
                DirectoryInfo result = Create(path);

                Assert.True(Directory.Exists(result.FullName));
                Assert.NotEqual(testDir.FullName, IOServices.RemoveTrailingSlash(result.FullName));
            });
        }
示例#8
0
        public void WindowsTrailingWhiteSpace()
        {
            // Windows will remove all nonsignificant whitespace in a path
            DirectoryInfo testDir    = Create(GetTestFilePath());
            var           components = IOInputs.GetWhiteSpace();

            Assert.All(components, (component) =>
            {
                string path          = IOServices.RemoveTrailingSlash(testDir.FullName) + component;
                DirectoryInfo result = Create(path);

                Assert.True(Directory.Exists(result.FullName));
                Assert.Equal(testDir.FullName, IOServices.RemoveTrailingSlash(result.FullName));
            });
        }
示例#9
0
文件: Exists.cs 项目: ikopylov/corefx
        [PlatformSpecific(PlatformID.Windows)] // In Windows, trailing whitespace in a path is trimmed appropriately
        public void TrailingWhitespaceExistence()
        {
            DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());

            Assert.All(IOInputs.GetWhiteSpace(), (component) =>
            {
                string path = testDir.FullName + component;
                Assert.True(Exists(path), path); // string concat in case Path.Combine() trims whitespace before Exists gets to it
                Assert.False(Exists(IOInputs.ExtendedPrefix + path), path);
            });

            Assert.All(IOInputs.GetSimpleWhiteSpace(), (component) =>
            {
                string path = GetTestFilePath(memberName: "Extended") + component;
                testDir     = Directory.CreateDirectory(IOInputs.ExtendedPrefix + path);
                Assert.False(Exists(path), path);
                Assert.True(Exists(testDir.FullName));
            });
        }