diff options
author | Anirudh Agnihotry <anirudhagnihotry098@gmail.com> | 2018-03-08 04:02:05 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-08 04:02:05 +0300 |
commit | 59f6987b7fc919a438060f6c502c3c9cf7c8af29 (patch) | |
tree | bc8bfe5d82fd37cc8f42666fd26cbf56450e1e22 /src/System.IO.FileSystem/tests | |
parent | 61aaf07bf486e457fa6d3f19f8335b0d536d7bca (diff) |
WhiteSpace and PrefixParent subdirectory names throw exception (#27810)
Diffstat (limited to 'src/System.IO.FileSystem/tests')
-rw-r--r-- | src/System.IO.FileSystem/tests/DirectoryInfo/CreateSubdirectory.cs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/System.IO.FileSystem/tests/DirectoryInfo/CreateSubdirectory.cs b/src/System.IO.FileSystem/tests/DirectoryInfo/CreateSubdirectory.cs index b1b707c41a..2e29f1ec6e 100644 --- a/src/System.IO.FileSystem/tests/DirectoryInfo/CreateSubdirectory.cs +++ b/src/System.IO.FileSystem/tests/DirectoryInfo/CreateSubdirectory.cs @@ -159,7 +159,16 @@ namespace System.IO.Tests [Theory, MemberData(nameof(SimpleWhiteSpace))] - [PlatformSpecific(TestPlatforms.Windows)] // Simple whitespace is trimmed in path + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)] + [PlatformSpecific(TestPlatforms.Windows)] + public void WindowsSimpleWhiteSpaceThrowsException(string component) + { + Assert.Throws<ArgumentException>(() => new DirectoryInfo(TestDirectory).CreateSubdirectory(component)); + } + + [Theory, + MemberData(nameof(SimpleWhiteSpace))] + [SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)] // Simple whitespace is trimmed in path public void WindowsSimpleWhiteSpace(string component) { DirectoryInfo result = new DirectoryInfo(TestDirectory).CreateSubdirectory(component); @@ -211,6 +220,16 @@ namespace System.IO.Tests Assert.Throws<ArgumentException>(() => testDir.CreateSubdirectory("//")); } + [Fact] + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)] + public void ParentDirectoryNameAsPrefixShouldThrow() + { + string randomName = GetTestFileName(); + DirectoryInfo di = Directory.CreateDirectory(Path.Combine(TestDirectory, randomName)); + + Assert.Throws<ArgumentException>(() => di.CreateSubdirectory(Path.Combine("..", randomName + "abc", GetTestFileName()))); + } + #endregion } } |