* Update tests for Path changes

Updates for https://github.com/dotnet/coreclr/pull/16478

* Add back Unix active issue (wishful thinking that this would get the same error on Unix)

* Address feedback
This commit is contained in:
Jeremy Kuhne 2018-02-22 12:13:29 -08:00 коммит произвёл GitHub
Родитель fecb772f06
Коммит 92afa6ec21
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
27 изменённых файлов: 516 добавлений и 193 удалений

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

@ -78,35 +78,28 @@ namespace System.ComponentModel.Composition
string filename = Path.GetTempFileName();
using (FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.None))
{
Assert.Throws<FileLoadException>(() =>
{
var catalog = catalogCreator(filename);
});
Assert.Throws<FileLoadException>(() => catalogCreator(filename));
}
}
public static void Constructor_NullFileNameAsCodeBaseArgument_ShouldThrowArgumentNull(Func<string, AssemblyCatalog> catalogCreator)
{
Assert.Throws<ArgumentNullException>("codeBase", () =>
{
var catalog = catalogCreator((string)null);
});
Assert.Throws<ArgumentNullException>("codeBase", () => catalogCreator(null));
}
public static void Constructor_EmptyFileNameAsCodeBaseArgument_ShouldThrowArgument(Func<string, AssemblyCatalog> catalogCreator)
{
Assert.Throws<ArgumentException>("codeBase", () =>
{
var catalog = catalogCreator("");
});
Assert.Throws<ArgumentException>("codeBase", () => catalogCreator(""));
}
public static void Constructor_InvalidFileNameAsCodeBaseArgument_ShouldThrowArgument(Func<string, AssemblyCatalog> catalogCreator)
{
Assert.Throws<ArgumentException>(() =>
{
var catalog = catalogCreator("??||>");
});
Assert.Throws<ArgumentException>(() => catalogCreator("??||>"));
}
public static void Constructor_InvalidFileNameAsCodeBaseArgument_ShouldThrowIO(Func<string, AssemblyCatalog> catalogCreator)
{
Assert.ThrowsAny<IOException>(() => catalogCreator("??||>"));
}
public static void Constructor_DirectoryAsCodeBaseArgument_ShouldThrowFileLoad(Func<string, AssemblyCatalog> catalogCreator)
@ -114,35 +107,24 @@ namespace System.ComponentModel.Composition
string directory = Environment.GetFolderPath(Environment.SpecialFolder.System);
Assert.True(Directory.Exists(directory));
Assert.Throws<FileLoadException>(() =>
{
var catalog = catalogCreator(directory);
});
Assert.Throws<FileLoadException>(() => catalogCreator(directory));
}
public static void Constructor_TooLongFileNameAsCodeBaseArgument_ShouldThrowPathTooLong(Func<string, AssemblyCatalog> catalogCreator)
{
Assert.Throws<PathTooLongException>(() =>
{
var catalog = catalogCreator(@"c:\This is a very long path\And Just to make sure\We will continue to make it very long\This is a very long path\And Just to make sure\We will continue to make it very long\This is a very long path\And Just to make sure\We will continue to make it very long\myassembly.dll");
});
catalogCreator(@"c:\This is a very long path\And Just to make sure\We will continue to make it very long\This is a very long path\And Just to make sure\We will continue to make it very long\This is a very long path\And Just to make sure\We will continue to make it very long\myassembly.dll"));
}
public static void Constructor_NonAssemblyFileNameAsCodeBaseArgument_ShouldThrowBadImageFormat(Func<string, AssemblyCatalog> catalogCreator)
{
string filename = Path.GetTempFileName();
Assert.Throws<BadImageFormatException>(() =>
{
var catalog = catalogCreator(filename);
});
Assert.Throws<BadImageFormatException>(() => catalogCreator(filename));
}
public static void Constructor_NonExistentFileNameAsCodeBaseArgument_ShouldThrowFileNotFound(Func<string, AssemblyCatalog> catalogCreator)
{
Assert.Throws<FileNotFoundException>(() =>
{
var catalog = catalogCreator(@"FileThat should not ever exist");
});
Assert.Throws<FileNotFoundException>(() => catalogCreator(@"FileThat should not ever exist"));
}
// Test Assembly variant of the APIs
@ -160,18 +142,12 @@ namespace System.ComponentModel.Composition
public static void Constructor_NullReflectionContextArgument_ShouldThrowArgumentNull(Func<ReflectionContext, AssemblyCatalog> catalogCreator)
{
AssertExtensions.Throws<ArgumentNullException>("reflectionContext", () =>
{
var catalog = catalogCreator(null);
});
AssertExtensions.Throws<ArgumentNullException>("reflectionContext", () => catalogCreator(null));
}
public static void Constructor_NullDefinitionOriginArgument_ShouldThrowArgumentNull(Func<ICompositionElement, AssemblyCatalog> catalogCreator)
{
AssertExtensions.Throws<ArgumentNullException>("definitionOrigin", () =>
{
var catalog = catalogCreator(null);
});
AssertExtensions.Throws<ArgumentNullException>("definitionOrigin", () => catalogCreator(null));
}
//=========================================================================================================================================
@ -215,8 +191,8 @@ namespace System.ComponentModel.Composition
}
[Fact]
[ActiveIssue(25498, TestPlatforms.AnyUnix)]
public void Constructor1_InvalidFileNameAsCodeBaseArgument_ShouldThrowArgument()
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void Constructor1_InvalidFileNameAsCodeBaseArgument_ShouldThrowArgument_Desktop()
{
AssemblyCatalogConstructorTests.Constructor_InvalidFileNameAsCodeBaseArgument_ShouldThrowArgument((s) =>
{
@ -224,6 +200,17 @@ namespace System.ComponentModel.Composition
});
}
[Fact]
[ActiveIssue(25498)] // Also see https://github.com/dotnet/corefx/issues/27269
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void Constructor1_InvalidFileNameAsCodeBaseArgument_ShouldThrowIO_Core()
{
AssemblyCatalogConstructorTests.Constructor_InvalidFileNameAsCodeBaseArgument_ShouldThrowIO((s) =>
{
return new AssemblyCatalog(s);
});
}
[Fact]
[ActiveIssue(25498)]
public void Constructor1_DirectoryAsCodeBaseArgument_ShouldThrowFileLoad()
@ -314,8 +301,8 @@ namespace System.ComponentModel.Composition
}
[Fact]
[ActiveIssue(25498, TestPlatforms.AnyUnix)]
public void Constructor2_InvalidFileNameAsCodeBaseArgument_ShouldThrowArgument()
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void Constructor2_InvalidFileNameAsCodeBaseArgument_ShouldThrowArgument_Desktop()
{
AssemblyCatalogConstructorTests.Constructor_InvalidFileNameAsCodeBaseArgument_ShouldThrowArgument((s) =>
{
@ -323,6 +310,17 @@ namespace System.ComponentModel.Composition
});
}
[Fact]
[ActiveIssue(25498)] // Also see https://github.com/dotnet/corefx/issues/27269
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void Constructor2_InvalidFileNameAsCodeBaseArgument_ShouldThrowArgument()
{
AssemblyCatalogConstructorTests.Constructor_InvalidFileNameAsCodeBaseArgument_ShouldThrowIO((s) =>
{
return new AssemblyCatalog(s, new AssemblyCatalogTestsReflectionContext());
});
}
[Fact]
[ActiveIssue(25498)]
public void Constructor2_DirectoryAsCodeBaseArgument_ShouldThrowFileLoad()
@ -412,7 +410,7 @@ namespace System.ComponentModel.Composition
}
[Fact]
[ActiveIssue(25498, TestPlatforms.AnyUnix)]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void Constructor3_InvalidFileNameAsCodeBaseArgument_ShouldThrowArgument()
{
AssemblyCatalogConstructorTests.Constructor_InvalidFileNameAsCodeBaseArgument_ShouldThrowArgument((s) =>
@ -421,6 +419,17 @@ namespace System.ComponentModel.Composition
});
}
[Fact]
[ActiveIssue(25498)] // // Also see https://github.com/dotnet/corefx/issues/27269
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void Constructor3_InvalidFileNameAsCodeBaseArgument_ShouldThrowIO_Core()
{
AssemblyCatalogConstructorTests.Constructor_InvalidFileNameAsCodeBaseArgument_ShouldThrowIO((s) =>
{
return new AssemblyCatalog(s, (ICompositionElement)new AssemblyCatalog(s));
});
}
[Fact]
[ActiveIssue(25498)]
public void Constructor3_DirectoryAsCodeBaseArgument_ShouldThrowFileLoad()
@ -509,8 +518,8 @@ namespace System.ComponentModel.Composition
}
[Fact]
[ActiveIssue(25498, TestPlatforms.AnyUnix)]
public void Constructor4_InvalidFileNameAsCodeBaseArgument_ShouldThrowArgument()
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void Constructor4_InvalidFileNameAsCodeBaseArgument_ShouldThrowArgument_Desktop()
{
AssemblyCatalogConstructorTests.Constructor_InvalidFileNameAsCodeBaseArgument_ShouldThrowArgument((s) =>
{
@ -518,6 +527,17 @@ namespace System.ComponentModel.Composition
});
}
[Fact]
[ActiveIssue(25498)] // Also see https://github.com/dotnet/corefx/issues/27269
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void Constructor4_InvalidFileNameAsCodeBaseArgument_ShouldThrowIO_Core()
{
AssemblyCatalogConstructorTests.Constructor_InvalidFileNameAsCodeBaseArgument_ShouldThrowIO((s) =>
{
return new AssemblyCatalog(s, new AssemblyCatalogTestsReflectionContext(), (ICompositionElement)new AssemblyCatalog(s));
});
}
[Fact]
[ActiveIssue(25498)]
public void Constructor4_DirectoryAsCodeBaseArgument_ShouldThrowFileLoad()
@ -780,10 +800,7 @@ namespace System.ComponentModel.Composition
catalog.Dispose();
var definition = ImportDefinitionFactory.Create();
ExceptionAssert.ThrowsDisposed(catalog, () =>
{
catalog.GetExports(definition);
});
ExceptionAssert.ThrowsDisposed(catalog, () => catalog.GetExports(definition));
}
[Fact]
@ -792,10 +809,7 @@ namespace System.ComponentModel.Composition
{
var catalog = CreateAssemblyCatalog();
AssertExtensions.Throws<ArgumentNullException>("definition", () =>
{
catalog.GetExports((ImportDefinition)null);
});
AssertExtensions.Throws<ArgumentNullException>("definition", () => catalog.GetExports(null));
}
[Fact]

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

@ -228,16 +228,6 @@ namespace System.ComponentModel.Composition
catalog.Dispose();
}
[Fact]
[ActiveIssue(25498, TestPlatforms.AnyUnix)] // typeof(System.IO.DirectoryNotFoundException): Could not find a part of the path '/HOME/HELIXBOT/DOTNETBUILD/WORK/E77C2FB6-5244-4437-8E27-6DD709101152/WORK/D9EBA0EA-A511-4F42-AC8B-AC8054AAF606/UNZIP/HTTP:/MICROSOFT.COM/MYASSEMBLY.DLL'.
public void AddAssembly1_NonExistentUriAsAssemblyFileNameArgument_ShouldNotSupportedException()
{
Assert.Throws<NotSupportedException>(() =>
{
var catalog = new DirectoryCatalog("http://microsoft.com/myassembly.dll");
});
}
[Fact]
public void AddAssembly1_NullPathArgument_ShouldThrowArugmentNull()
{
@ -252,16 +242,6 @@ namespace System.ComponentModel.Composition
new DirectoryCatalog(""));
}
[Fact]
[ActiveIssue(25498, TestPlatforms.AnyUnix)] // typeof(System.IO.DirectoryNotFoundException): Could not find a part of the path '/HOME/HELIXBOT/DOTNETBUILD/WORK/E77C2FB6-5244-4437-8E27-6DD709101152/WORK/D9EBA0EA-A511-4F42-AC8B-AC8054AAF606/UNZIP/*'.
public void AddAssembly1_InvalidPathName_ShouldThrowDirectoryNotFound()
{
Assert.Throws<ArgumentException>(() =>
{
var c1 = new DirectoryCatalog("*");
});
}
[Fact]
[ActiveIssue(25498)]
public void AddAssembly1_TooLongPathNameArgument_ShouldThrowPathTooLongException()

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

@ -90,7 +90,7 @@ namespace System.Drawing.Imaging.Tests
[ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalTheory(Helpers.GdiplusIsAvailable)]
[InlineData(@"fileNo*-//\\#@(found")]
[InlineData("bad\0name")]
[InlineData("")]
public void Ctor_InvalidPath_ThrowsArgumentException(string path)
{
@ -464,7 +464,7 @@ namespace System.Drawing.Imaging.Tests
[ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalTheory(Helpers.GdiplusIsAvailable)]
[InlineData(@"fileNo*-//\\#@(found")]
[InlineData("bad\0path")]
[InlineData("")]
public void Ctor_InvalidPathI_ThrowsArgumentException(string fileName)
{
@ -749,7 +749,7 @@ namespace System.Drawing.Imaging.Tests
[ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalTheory(Helpers.GdiplusIsAvailable)]
[InlineData(@"fileNo*-//\\#@(found")]
[InlineData("bad\0path")]
[InlineData("")]
public void Ctor_InvalidPathII_ThrowsArgumentException(string fileName)
{
@ -940,7 +940,7 @@ namespace System.Drawing.Imaging.Tests
[ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalTheory(Helpers.GdiplusIsAvailable)]
[InlineData(@"fileNo*-//\\#@(found")]
[InlineData("bad\0path")]
[InlineData("")]
public void Static_GetMetafileHeader_InvalidPath_ThrowsArgumentException(string fileName)
{

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

@ -243,6 +243,7 @@ namespace System.IO.Compression.Tests
/// when an attempt is made to extract them.
/// </summary>
[Theory]
[ActiveIssue(27269)]
[InlineData("WindowsInvalid_FromUnix", null)]
[InlineData("WindowsInvalid_FromWindows", null)]
[InlineData("NullCharFileName_FromWindows", "path")]

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

@ -29,7 +29,7 @@ namespace System.IO.FileSystem.DriveInfoTests
[InlineData(@"\\share", null)]
[InlineData(@"\\", null)]
[InlineData("c ", null)]
[InlineData("", "path")]
// [InlineData("", "path")] // https://github.com/dotnet/corefx/issues/27269
[InlineData(" c", null)]
public void Ctor_InvalidPath_ThrowsArgumentException(string driveName, string paramName)
{

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

@ -29,7 +29,6 @@ namespace System.IO
OriginalPath = originalPath ?? throw new ArgumentNullException("path");
fullPath = fullPath ?? originalPath;
Debug.Assert(!isNormalized || !PathInternal.IsPartiallyQualified(fullPath), $"'{fullPath}' should be fully qualified if normalized");
fullPath = isNormalized ? fullPath : Path.GetFullPath(fullPath);
_name = fileName ?? (PathHelpers.IsRoot(fullPath) ?

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

@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
namespace System.IO
{
partial class FileSystemInfo
@ -19,6 +21,8 @@ namespace System.IO
? (FileSystemInfo)new DirectoryInfo(fullPath, fileName: fileName, isNormalized: true)
: new FileInfo(fullPath, fileName: fileName, isNormalized: true);
Debug.Assert(!PathInternal.IsPartiallyQualified(fullPath), $"'{fullPath}' should be fully qualified when constructed from directory enumeration");
info.Init(ref fileStatus);
return info;
}

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

@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
using System.IO.Enumeration;
namespace System.IO
@ -27,6 +28,8 @@ namespace System.IO
? (FileSystemInfo) new DirectoryInfo(fullPath, fileName: new string(findData.FileName), isNormalized: true)
: new FileInfo(fullPath, fileName: new string(findData.FileName), isNormalized: true);
Debug.Assert(!PathInternal.IsPartiallyQualified(fullPath), $"'{fullPath}' should be fully qualified when constructed from directory enumeration");
info.Init(findData._info);
return info;
}

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

@ -34,14 +34,21 @@ namespace System.IO.Tests
}
[Theory, MemberData(nameof(PathsWithInvalidCharacters))]
public void PathWithInvalidCharactersAsPath_ThrowsArgumentException(string invalidPath)
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void PathWithInvalidCharactersAsPath_Desktop(string invalidPath)
{
if (invalidPath.Equals(@"\\?\") && !PathFeatures.IsUsingLegacyPathNormalization())
AssertExtensions.ThrowsAny<IOException, UnauthorizedAccessException>(() => Create(invalidPath));
else if (invalidPath.Contains(@"\\?\") && !PathFeatures.IsUsingLegacyPathNormalization())
Assert.Throws<DirectoryNotFoundException>(() => Create(invalidPath));
Assert.Throws<ArgumentException>(() => Create(invalidPath));
}
[ActiveIssue(27269)]
[Theory, MemberData(nameof(PathsWithInvalidCharacters))]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void PathWithInvalidCharactersAsPath_Core(string invalidPath)
{
if (invalidPath.Contains('\0'))
Assert.Throws<ArgumentException>("path", () => Create(invalidPath));
else
Assert.Throws<ArgumentException>(() => Create(invalidPath));
Assert.Throws<IOException>(() => Create(invalidPath));
}
[Fact]
@ -203,11 +210,29 @@ namespace System.IO.Tests
#region PlatformSpecific
[Theory, MemberData(nameof(PathsWithInvalidColons))]
[PlatformSpecific(TestPlatforms.Windows)] // invalid colons throws ArgumentException
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Versions of netfx older than 4.6.2 throw an ArgumentException instead of NotSupportedException. Until all of our machines run netfx against the actual latest version, these will fail.")]
public void PathWithInvalidColons_ThrowsNotSupportedException(string invalidPath)
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void PathWithInvalidColons_ThrowsNotSupportedException_Desktop(string invalidPath)
{
Assert.Throws<NotSupportedException>(() => Create(invalidPath));
if (PathFeatures.IsUsingLegacyPathNormalization())
{
Assert.Throws<ArgumentException>(() => Create(invalidPath));
}
else
{
Assert.Throws<NotSupportedException>(() => Create(invalidPath));
}
}
[ActiveIssue(27269)]
[Theory, MemberData(nameof(PathsWithInvalidColons))]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void PathsWithInvalidColons_ThrowIOException_Core(string invalidPath)
{
// You can't actually create a directory with a colon in it. It was a preemptive
// check, now we let the OS give us failures on usage.
Assert.ThrowsAny<IOException>(() => Create(invalidPath));
}
[ConditionalFact(nameof(AreAllLongPathsAvailable))]
@ -308,13 +333,33 @@ namespace System.IO.Tests
}
[Theory,
MemberData(nameof(WhiteSpace))]
[PlatformSpecific(TestPlatforms.Windows)] // whitespace as path throws ArgumentException on Windows
public void WindowsWhiteSpaceAsPath_ThrowsArgumentException(string path)
MemberData(nameof(SimpleWhiteSpace))]
[PlatformSpecific(TestPlatforms.Windows)]
public void WindowsSimpleWhiteSpaceAsPath_ThrowsArgumentException(string path)
{
Assert.Throws<ArgumentException>(() => Create(path));
}
[Theory,
MemberData(nameof(ControlWhiteSpace))]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void WindowsControlWhiteSpaceAsPath_ThrowsArgumentException_Desktop(string path)
{
Assert.Throws<ArgumentException>(() => Create(path));
}
[ActiveIssue(27269)]
[Theory,
MemberData(nameof(ControlWhiteSpace))]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void WindowsWhiteSpaceAsPath_ThrowsIOException_Core(string path)
{
Assert.Throws<IOException>(() => Create(path));
}
[Theory,
MemberData(nameof(WhiteSpace))]
[PlatformSpecific(TestPlatforms.AnyUnix)] // whitespace as path allowed
@ -397,13 +442,24 @@ namespace System.IO.Tests
}
[Theory,
MemberData(nameof(PathsWithAlternativeDataStreams))]
MemberData(nameof(PathsWithColons))]
[PlatformSpecific(TestPlatforms.Windows)] // alternate data streams
public void PathWithAlternateDataStreams_ThrowsNotSupportedException(string path)
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void PathWithColons_ThrowsNotSupportedException_Desktop(string path)
{
Assert.Throws<NotSupportedException>(() => Create(path));
}
[ActiveIssue(27269)]
[Theory,
MemberData(nameof(PathsWithColons))]
[PlatformSpecific(TestPlatforms.Windows)] // alternate data streams
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void PathWithColons_ThrowsIOException_Core(string path)
{
Assert.ThrowsAny<IOException>(() => Create(Path.Combine(TestDirectory, path)));
}
[Theory,
MemberData(nameof(PathsWithReservedDeviceNames))]
[PlatformSpecific(TestPlatforms.Windows)] // device name prefixes
@ -424,19 +480,40 @@ namespace System.IO.Tests
[Theory,
MemberData(nameof(UncPathsWithoutShareName))]
[PlatformSpecific(TestPlatforms.Windows)] // UNC shares
public void UncPathWithoutShareNameAsPath_ThrowsArgumentException(string path)
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void UncPathWithoutShareNameAsPath_ThrowsArgumentException_Desktop(string path)
{
Assert.Throws<ArgumentException>(() => Create(path));
}
[ActiveIssue(27269)]
[Theory,
MemberData(nameof(UncPathsWithoutShareName))]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void UncPathWithoutShareNameAsPath_ThrowsIOException_Core(string path)
{
Assert.ThrowsAny<IOException>(() => Create(path));
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // UNC shares
public void UNCPathWithOnlySlashes()
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void UNCPathWithOnlySlashes_Desktop()
{
Assert.Throws<ArgumentException>(() => Create("//"));
}
[ActiveIssue(27269)]
[Fact]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void UNCPathWithOnlySlashes_Core()
{
Assert.ThrowsAny<IOException>(() => Create("//"));
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // drive labels
[ActiveIssue(20117, TargetFrameworkMonikers.Uap)]

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

@ -11,7 +11,7 @@ namespace System.IO.Tests
{
#region Utilities
public static TheoryData WindowsInvalidUnixValid = new TheoryData<string> { " ", " ", "\n", ">", "<", "\t" };
protected virtual bool TestFiles { get { return true; } } // True if the virtual GetEntries mmethod returns files
protected virtual bool TestDirectories { get { return true; } } // True if the virtual GetEntries mmethod returns Directories
@ -205,37 +205,97 @@ namespace System.IO.Tests
#region PlatformSpecific
[Fact]
public void InvalidPath()
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void InvalidPath_Desktop()
{
foreach (char invalid in Path.GetInvalidFileNameChars())
{
if (invalid == '/' || invalid == '\\')
string badPath = string.Format($"{TestDirectory}{Path.DirectorySeparatorChar}te{invalid}st");
switch (invalid)
{
Assert.Throws<DirectoryNotFoundException>(() => GetEntries(Path.Combine(TestDirectory, string.Format("te{0}st", invalid.ToString()))));
case '/':
case '\\':
Assert.Throws<DirectoryNotFoundException>(() => GetEntries(badPath));
break;
case ':':
Assert.Throws<NotSupportedException>(() => GetEntries(badPath));
break;
case '\0':
Assert.Throws<ArgumentException>(() => GetEntries(badPath));
break;
default:
Assert.Throws<ArgumentException>(() => GetEntries(badPath));
break;
}
else if (invalid == ':')
}
}
[ActiveIssue(27269)]
[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void InvalidPath_Core()
{
foreach (char invalid in Path.GetInvalidFileNameChars())
{
string badPath = string.Format($"{TestDirectory}{Path.DirectorySeparatorChar}te{invalid}st");
switch (invalid)
{
if (FileSystemDebugInfo.IsCurrentDriveNTFS())
Assert.Throws<NotSupportedException>(() => GetEntries(Path.Combine(TestDirectory, string.Format("te{0}st", invalid.ToString()))));
}
else
{
Assert.Throws<ArgumentException>(() => GetEntries(Path.Combine(TestDirectory, string.Format("te{0}st", invalid.ToString()))));
case '/':
case '\\':
case ':':
Assert.Throws<DirectoryNotFoundException>(() => GetEntries(badPath));
break;
case '\0':
Assert.Throws<ArgumentException>(() => GetEntries(badPath));
break;
default:
Assert.Throws<IOException>(() => GetEntries(badPath));
break;
}
}
}
[Theory,
MemberData(nameof(WindowsInvalidUnixValid))]
[PlatformSpecific(TestPlatforms.Windows)] // Windows-only Invalid chars in path
public void WindowsInvalidCharsPath(string invalid)
InlineData(" "),
InlineData(" ")]
[PlatformSpecific(TestPlatforms.Windows)]
public void WindowsWhitespaceOnlyPath(string invalid)
{
Assert.Throws<ArgumentException>(() => GetEntries(invalid));
}
[Theory,
MemberData(nameof(WindowsInvalidUnixValid))]
InlineData("\n"),
InlineData(">"),
InlineData("<"),
InlineData("\t")]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void WindowsInvalidCharsPath_Desktop(string invalid)
{
Assert.Throws<ArgumentException>(() => GetEntries(invalid));
}
[ActiveIssue(27269)]
[Theory,
InlineData("\n"),
InlineData(">"),
InlineData("<"),
InlineData("\t")]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void WindowsInvalidCharsPath_Core(string invalid)
{
Assert.Throws<IOException>(() => GetEntries(invalid));
}
[Theory,
InlineData(" "),
InlineData(" "),
InlineData("\n"),
InlineData(">"),
InlineData("<"),
InlineData("\t")]
[PlatformSpecific(TestPlatforms.AnyUnix)] // Unix-only valid chars in file path
public void UnixValidCharsFilePath(string valid)
{
@ -251,7 +311,12 @@ namespace System.IO.Tests
}
[Theory,
MemberData(nameof(WindowsInvalidUnixValid))]
InlineData(" "),
InlineData(" "),
InlineData("\n"),
InlineData(">"),
InlineData("<"),
InlineData("\t")]
[PlatformSpecific(TestPlatforms.AnyUnix)] // Windows-only invalid chars in directory path
public void UnixValidCharsDirectoryPath(string valid)
{

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

@ -985,7 +985,12 @@ namespace System.IO.Tests
}
[Theory,
MemberData(nameof(WindowsInvalidUnixValid))]
InlineData(" "),
InlineData(" "),
InlineData("\n"),
InlineData(">"),
InlineData("<"),
InlineData("\t")]
[PlatformSpecific(TestPlatforms.AnyUnix)] // Unix-valid chars in file search patterns
public void UnixSearchPatternFileValidChar(string valid)
{
@ -999,7 +1004,12 @@ namespace System.IO.Tests
}
[Theory,
MemberData(nameof(WindowsInvalidUnixValid))]
InlineData(" "),
InlineData(" "),
InlineData("\n"),
InlineData(">"),
InlineData("<"),
InlineData("\t")]
[PlatformSpecific(TestPlatforms.AnyUnix)] // Unix-valid chars in directory search patterns
public void UnixSearchPatternDirectoryValidChar(string valid)
{

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

@ -242,8 +242,9 @@ namespace System.IO.Tests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // Wild characters in path, wild chars are normal chars on Unix
public void WindowsWildCharacterPath()
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void WindowsWildCharacterPath_Desktop()
{
Assert.Throws<ArgumentException>(() => Move("*", GetTestFilePath()));
Assert.Throws<ArgumentException>(() => Move(TestDirectory, "*"));
@ -251,6 +252,18 @@ namespace System.IO.Tests
Assert.Throws<ArgumentException>(() => Move(TestDirectory, "*Test"));
}
[ActiveIssue(27269)]
[Fact]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void WindowsWildCharacterPath_Core()
{
Assert.ThrowsAny<IOException>(() => Move(Path.Combine(TestDirectory, "*"), GetTestFilePath()));
Assert.ThrowsAny<IOException>(() => Move(TestDirectory, Path.Combine(TestDirectory, "*")));
Assert.ThrowsAny<IOException>(() => Move(TestDirectory, Path.Combine(TestDirectory, "Test*t")));
Assert.ThrowsAny<IOException>(() => Move(TestDirectory, Path.Combine(TestDirectory, "*Test")));
}
[Fact]
[PlatformSpecific(TestPlatforms.AnyUnix)] // Wild characters in path are allowed
public void UnixWildCharacterPath()
@ -278,17 +291,13 @@ namespace System.IO.Tests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // Whitespace path causes ArgumentException
public void WindowsWhitespacePath()
[PlatformSpecific(TestPlatforms.Windows)]
public void WindowsEmptyPath()
{
DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
Assert.Throws<ArgumentException>(() => Move(testDir.FullName, " "));
Assert.Throws<ArgumentException>(() => Move(testDir.FullName, "\n"));
Assert.Throws<ArgumentException>(() => Move(testDir.FullName, ""));
Assert.Throws<ArgumentException>(() => Move(testDir.FullName, ">"));
Assert.Throws<ArgumentException>(() => Move(testDir.FullName, "<"));
Assert.Throws<ArgumentException>(() => Move(testDir.FullName, "\0"));
Assert.Throws<ArgumentException>(() => Move(testDir.FullName, "\t"));
}
[Fact]

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

@ -140,27 +140,32 @@ namespace System.IO.Tests
[Theory,
MemberData(nameof(ControlWhiteSpace))]
[PlatformSpecific(TestPlatforms.Windows)] // Control whitespace in path throws ArgumentException
public void WindowsControlWhiteSpace(string component)
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void WindowsControlWhiteSpace_Desktop(string component)
{
// CreateSubdirectory will throw when passed a path with control whitespace e.g. "\t"
string path = IOServices.RemoveTrailingSlash(GetTestFileName());
Assert.Throws<ArgumentException>(() => new DirectoryInfo(TestDirectory).CreateSubdirectory(component));
}
[ActiveIssue(27269)]
[Theory,
MemberData(nameof(ControlWhiteSpace))]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void WindowsControlWhiteSpace_Core(string component)
{
Assert.Throws<IOException>(() => new DirectoryInfo(TestDirectory).CreateSubdirectory(component));
}
[Theory,
MemberData(nameof(SimpleWhiteSpace))]
[PlatformSpecific(TestPlatforms.Windows)] // Simple whitespace is trimmed in path
public void WindowsSimpleWhiteSpace(string component)
{
// CreateSubdirectory trims all simple whitespace, returning us the parent directory
// that called CreateSubdirectory
string path = IOServices.RemoveTrailingSlash(GetTestFileName());
DirectoryInfo result = new DirectoryInfo(TestDirectory).CreateSubdirectory(component);
Assert.True(Directory.Exists(result.FullName));
Assert.Equal(TestDirectory, IOServices.RemoveTrailingSlash(result.FullName));
}
[Theory,
@ -170,7 +175,6 @@ namespace System.IO.Tests
{
new DirectoryInfo(TestDirectory).CreateSubdirectory(path);
Assert.True(Directory.Exists(Path.Combine(TestDirectory, path)));
}
[Theory,

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

@ -13,7 +13,7 @@ namespace System.IO.Tests
{
#region Utilities
public static TheoryData WindowsInvalidUnixValid = new TheoryData<string> { " ", " ", "\n", ">", "<", "\t" };
public static TheoryData WindowsInvalidUnixValid = new TheoryData<string> { " ", };
public virtual void Copy(string source, string dest)
{
File.Copy(source, dest);
@ -161,9 +161,10 @@ namespace System.IO.Tests
#region PlatformSpecific
[Theory,
MemberData(nameof(WindowsInvalidUnixValid))]
[PlatformSpecific(TestPlatforms.Windows)] // Whitespace path throws ArgumentException
public void WindowsWhitespacePath(string invalid)
InlineData(" "),
InlineData(" ")]
[PlatformSpecific(TestPlatforms.Windows)]
public void WindowsAllSpacePath(string invalid)
{
string testFile = GetTestFilePath();
File.Create(testFile).Dispose();
@ -173,13 +174,52 @@ namespace System.IO.Tests
}
[Theory,
MemberData(nameof(WindowsInvalidUnixValid))]
[PlatformSpecific(TestPlatforms.AnyUnix)] // Whitespace path allowed
public void UnixWhitespacePath(string valid)
InlineData("\n"),
InlineData(">"),
InlineData("<"),
InlineData("\t")]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void WindowsInvalidCharsPath_Desktop(string invalid)
{
string testFile = GetTestFilePath();
File.Create(testFile).Dispose();
Assert.Throws<ArgumentException>(() => Copy(testFile, invalid));
Assert.Throws<ArgumentException>(() => Copy(invalid, testFile));
}
[ActiveIssue(27269)]
[Theory,
InlineData("\n"),
InlineData(">"),
InlineData("<"),
InlineData("\t")]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void WindowsInvalidCharsPath_Core(string invalid)
{
string testFile = GetTestFilePath();
File.Create(testFile).Dispose();
Assert.Throws<IOException>(() => Copy(testFile, invalid));
Assert.Throws<IOException>(() => Copy(invalid, testFile));
}
[Theory,
InlineData(" "),
InlineData(" "),
InlineData("\n"),
InlineData(">"),
InlineData("<"),
InlineData("\t")]
[PlatformSpecific(TestPlatforms.AnyUnix)]
public void UnixInvalidWindowsPaths(string valid)
{
// Unix allows whitespaces paths that aren't valid on Windows
string testFile = GetTestFilePath();
File.Create(testFile).Dispose();
Copy(testFile, Path.Combine(TestDirectory, valid));
Assert.True(File.Exists(testFile));
Assert.True(File.Exists(Path.Combine(TestDirectory, valid)));

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

@ -201,8 +201,9 @@ namespace System.IO.Tests
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // Invalid file name with wildcard characters on Windows
public void WindowsWildCharacterPath()
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void WindowsWildCharacterPath_Desktop()
{
DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
Assert.Throws<ArgumentException>(() => Create(Path.Combine(testDir.FullName, "dls;d", "442349-0", "v443094(*)(+*$#$*", new string(Path.DirectorySeparatorChar, 3))));
@ -211,20 +212,55 @@ namespace System.IO.Tests
Assert.Throws<ArgumentException>(() => Create(Path.Combine(testDir.FullName, "*Tes*t")));
}
[ActiveIssue(27269)]
[Fact]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void WindowsWildCharacterPath_Core()
{
DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
Assert.ThrowsAny<IOException>(() => Create(Path.Combine(testDir.FullName, "dls;d", "442349-0", "v443094(*)(+*$#$*", new string(Path.DirectorySeparatorChar, 3))));
Assert.ThrowsAny<IOException>(() => Create(Path.Combine(testDir.FullName, "*")));
Assert.ThrowsAny<IOException>(() => Create(Path.Combine(testDir.FullName, "Test*t")));
Assert.ThrowsAny<IOException>(() => Create(Path.Combine(testDir.FullName, "*Tes*t")));
}
[Theory,
InlineData(" "),
InlineData(" "),
InlineData(""),
InlineData("\0"),
InlineData(" ")]
[PlatformSpecific(TestPlatforms.Windows)]
public void WindowsEmptyPath(string path)
{
Assert.Throws<ArgumentException>(() => Create(path));
}
[Theory,
InlineData("\n"),
InlineData(">"),
InlineData("<"),
InlineData("\0"),
InlineData("\t")]
[PlatformSpecific(TestPlatforms.Windows)] // Invalid file name with whitespace on Windows
public void WindowsWhitespacePath(string path)
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void WindowsInvalidPath_Desktop(string path)
{
Assert.Throws<ArgumentException>(() => Create(path));
}
[ActiveIssue(27269)]
[Theory,
InlineData("\n"),
InlineData(">"),
InlineData("<"),
InlineData("\t")]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void WindowsInvalidPath_Core(string path)
{
Assert.ThrowsAny<IOException>(() => Create(Path.Combine(TestDirectory, path)));
}
[Fact]
[PlatformSpecific(TestPlatforms.AnyUnix)]
public void CreateNullThrows_Unix()

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

@ -231,7 +231,7 @@ namespace System.IO.Tests
[Theory,
MemberData(nameof(PathsWithAlternativeDataStreams))]
MemberData(nameof(PathsWithColons))]
[PlatformSpecific(TestPlatforms.Windows)] // alternate data stream
public void PathWithAlternateDataStreams_ReturnsFalse(string component)
{

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

@ -44,17 +44,27 @@ namespace System.IO.Tests
}
[Theory, MemberData(nameof(PathsWithInvalidCharacters))]
public void PathWithIllegalCharacters(string invalidPath)
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void PathWithIllegalCharacters_Desktop(string invalidPath)
{
FileInfo testFile = new FileInfo(GetTestFilePath());
testFile.Create().Dispose();
// Under legacy normalization we kick \\?\ paths back as invalid with ArgumentException
// New style we don't prevalidate \\?\ at all
if (invalidPath.Contains(@"\\?\") && !PathFeatures.IsUsingLegacyPathNormalization())
Assert.Throws<IOException>(() => Move(testFile.FullName, invalidPath));
else
Assert.Throws<ArgumentException>(() => Move(testFile.FullName, invalidPath));
}
[ActiveIssue(27269)]
[Theory, MemberData(nameof(PathsWithInvalidCharacters))]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void PathWithIllegalCharacters_Core(string invalidPath)
{
FileInfo testFile = new FileInfo(GetTestFilePath());
testFile.Create().Dispose();
if (invalidPath.Contains('\0'.ToString()))
Assert.Throws<ArgumentException>(() => Move(testFile.FullName, invalidPath));
else
Assert.ThrowsAny<IOException>(() => Move(testFile.FullName, invalidPath));
}
[Fact]
@ -225,17 +235,36 @@ namespace System.IO.Tests
[Theory, MemberData(nameof(PathsWithInvalidColons))]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Versions of netfx older than 4.6.2 throw an ArgumentException instead of NotSupportedException. Until all of our machines run netfx against the actual latest version, these will fail.")]
public void WindowsPathWithIllegalColons(string invalidPath)
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void WindowsPathWithIllegalColons_Desktop(string invalidPath)
{
FileInfo testFile = new FileInfo(GetTestFilePath());
testFile.Create().Dispose();
Assert.Throws<NotSupportedException>(() => Move(testFile.FullName, invalidPath));
if (PathFeatures.IsUsingLegacyPathNormalization())
{
Assert.Throws<ArgumentException>(() => Move(testFile.FullName, invalidPath));
}
else
{
Assert.Throws<NotSupportedException>(() => Move(testFile.FullName, invalidPath));
}
}
[ActiveIssue(27269)]
[Theory, MemberData(nameof(PathsWithInvalidColons))]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void WindowsPathWithIllegalColons_Core(string invalidPath)
{
FileInfo testFile = new FileInfo(GetTestFilePath());
testFile.Create().Dispose();
Assert.ThrowsAny<IOException>(() => Move(testFile.FullName, invalidPath));
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // Wild characters in path throw ArgumentException
public void WindowsWildCharacterPath()
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void WindowsWildCharacterPath_Desktop()
{
Assert.Throws<ArgumentException>(() => Move("*", GetTestFilePath()));
Assert.Throws<ArgumentException>(() => Move(GetTestFilePath(), "*"));
@ -243,6 +272,19 @@ namespace System.IO.Tests
Assert.Throws<ArgumentException>(() => Move(GetTestFilePath(), "*Test"));
}
[ActiveIssue(27269)]
[Fact]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void WindowsWildCharacterPath_Core()
{
Assert.Throws<FileNotFoundException>(() => Move(Path.Combine(TestDirectory, "*"), GetTestFilePath()));
Assert.Throws<FileNotFoundException>(() => Move(GetTestFilePath(), Path.Combine(TestDirectory, "*")));
Assert.Throws<FileNotFoundException>(() => Move(GetTestFilePath(), Path.Combine(TestDirectory, "Test*t")));
Assert.Throws<FileNotFoundException>(() => Move(GetTestFilePath(), Path.Combine(TestDirectory, "*Test")));
}
[Fact]
[PlatformSpecific(TestPlatforms.AnyUnix)] // Wild characters in path are allowed
public void UnixWildCharacterPath()
@ -268,9 +310,30 @@ namespace System.IO.Tests
}
[Theory,
MemberData(nameof(WhiteSpace))]
[PlatformSpecific(TestPlatforms.Windows)] // Whitespace in path throws ArgumentException
public void WindowsWhitespacePath(string whitespace)
MemberData(nameof(ControlWhiteSpace))]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void WindowsControlPath_Desktop(string whitespace)
{
FileInfo testFile = new FileInfo(GetTestFilePath());
Assert.Throws<ArgumentException>(() => Move(testFile.FullName, whitespace));
}
[ActiveIssue(27269)]
[Theory,
MemberData(nameof(ControlWhiteSpace))]
[PlatformSpecific(TestPlatforms.Windows)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void WindowsControlPath_Core(string whitespace)
{
FileInfo testFile = new FileInfo(GetTestFilePath());
Assert.ThrowsAny<IOException>(() => Move(testFile.FullName, Path.Combine(TestDirectory, whitespace)));
}
[Theory,
MemberData(nameof(SimpleWhiteSpace))]
[PlatformSpecific(TestPlatforms.Windows)]
public void WindowsSimpleWhitespacePath(string whitespace)
{
FileInfo testFile = new FileInfo(GetTestFilePath());
Assert.Throws<ArgumentException>(() => Move(testFile.FullName, whitespace));

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

@ -28,7 +28,7 @@ namespace System.IO.Tests
public static TheoryData WhiteSpace = IOInputs.GetWhiteSpace().ToTheoryData();
public static TheoryData UncPathsWithoutShareName = IOInputs.GetUncPathsWithoutShareName().ToTheoryData();
public static TheoryData PathsWithReservedDeviceNames = IOInputs.GetPathsWithReservedDeviceNames().ToTheoryData();
public static TheoryData PathsWithAlternativeDataStreams = IOInputs.GetPathsWithAlternativeDataStreams().ToTheoryData();
public static TheoryData PathsWithColons = IOInputs.GetPathsWithColons().ToTheoryData();
public static TheoryData PathsWithComponentLongerThanMaxComponent = IOInputs.GetPathsWithComponentLongerThanMaxComponent().ToTheoryData();
public static TheoryData ControlWhiteSpace = IOInputs.GetControlWhiteSpace().ToTheoryData();
public static TheoryData NonControlWhiteSpace = IOInputs.GetNonControlWhiteSpace().ToTheoryData();

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

@ -152,7 +152,7 @@ internal static class IOInputs
}
}
public static IEnumerable<string> GetPathsWithAlternativeDataStreams()
public static IEnumerable<string> GetPathsWithColons()
{
yield return @"AA:";
yield return @"AAA:";

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

@ -57,25 +57,12 @@ internal static class TestData
{
get
{
TheoryData<string> data = new TheoryData<string>();
// NOTE: That I/O treats "file"/http" specially and throws ArgumentException.
// Otherwise, it treats all other urls as alternative data streams
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // alternate data streams, drive labels, etc.
TheoryData<string> data = new TheoryData<string>
{
data.Add("\0");
data.Add("middle\0path");
data.Add("trailing\0");
data.Add(@"\\?\");
data.Add(@"\\?\UNC\");
data.Add(@"\\?\UNC\LOCALHOST");
}
else
{
data.Add("\0");
data.Add("middle\0path");
data.Add("trailing\0");
}
"\0",
"middle\0path",
"trailing\0"
};
foreach (char c in s_invalidFileNameChars)
{

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

@ -286,11 +286,12 @@ namespace System.Net.Sockets.Tests
AssertExtensions.Throws<ArgumentException>("path", null, () =>
{
// Existence is validated on send
SendPackets(type, new SendPacketsElement(" \t "), 0);
SendPackets(type, new SendPacketsElement(" "), 0);
});
}
[Theory]
[ActiveIssue(27269)]
[InlineData(SocketImplementationType.APM)]
[InlineData(SocketImplementationType.Async)]
[PlatformSpecific(TestPlatforms.Windows)] // valid filename chars on Unix

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

@ -76,6 +76,7 @@ namespace System.Xml.Tests
|| e is FileNotFoundException
|| e is FormatException
|| e is UnauthorizedAccessException
|| e is IOException
|| e is XmlException);
}

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

@ -1616,7 +1616,7 @@ namespace System.Xml.Tests
{
try
{
LoadXSL("\\\\", XslInputType.URI, readerType, new XmlUrlResolver());
LoadXSL(" ", XslInputType.URI, readerType, new XmlUrlResolver());
}
catch (System.ArgumentException)
{
@ -2913,7 +2913,7 @@ namespace System.Xml.Tests
if (LoadXSL("showParam.xsl", xslInputType, readerType) == 1)
{
Assert.Throws<System.ArgumentException>(() => xslt.Transform(szFullFilename, "\\\\"));
Assert.Throws<System.ArgumentException>(() => xslt.Transform(szFullFilename, " "));
return;
}

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

@ -44,7 +44,7 @@ namespace System.Xml.Tests
public String szDefaultNS = "urn:my-object";
public String szEmpty = "";
public String szInvalid = "*?%(){}[]&!@#$";
public String szInvalid = "*?%(){}\0[]&!@#$";
public String szLongString = "ThisIsAVeryLongStringToBeStoredAsAVariableToDetermineHowLargeThisBufferForAVariableNameCanBeAndStillFunctionAsExpected";
public String szLongNS = "http://www.microsoft.com/this/is/a/very/long/namespace/uri/to/do/the/api/testing/for/xslt/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/";
public String[] szWhiteSpace = { " ", "\n", "\t", "\r", "\t\n \r\t" };

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

@ -1413,7 +1413,7 @@ namespace System.Xml.Tests
{
try
{
LoadXSL("\\\\", InputType.URI, readerType);
LoadXSL(" ", InputType.URI, readerType);
}
catch (System.ArgumentException)
{
@ -2522,7 +2522,7 @@ namespace System.Xml.Tests
if (LoadXSL("showParam.xsl", inputType, readerType) == 1)
{
Assert.Throws<System.ArgumentException>(() => xslt.Transform(szFullFilename, "\\\\"));
Assert.Throws<System.ArgumentException>(() => xslt.Transform(szFullFilename, " "));
return;
}

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

@ -57,7 +57,7 @@ namespace System.Xml.Tests
public String szDefaultNS = "urn:my-object";
public String szEmpty = "";
public String szInvalid = "*?%(){}[]&!@#$";
public String szInvalid = "*?%()\0{}[]&!@#$";
public String szLongString = "ThisIsAVeryLongStringToBeStoredAsAVariableToDetermineHowLargeThisBufferForAVariableNameCanBeAndStillFunctionAsExpected";
public String szLongNS = "http://www.miocrosoft.com/this/is/a/very/long/namespace/uri/to/do/the/api/testing/for/xslt/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/";
public String[] szWhiteSpace = { " ", "\n", "\t", "\r", "\t\n \r\t" };

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

@ -712,10 +712,26 @@ namespace System.IO.Tests
}
[PlatformSpecific(TestPlatforms.Windows)] // Tests Windows-specific invalid paths
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
[Theory]
[InlineData("http://www.microsoft.com")]
[InlineData("file://www.microsoft.com")]
public static void GetFullPath_Windows_URIFormatNotSupported(string path)
public static void GetFullPath_Windows_URIFormatNotSupported_Desktop(string path)
{
// Throws via our invalid colon filtering
if (!PathFeatures.IsUsingLegacyPathNormalization())
{
Assert.Throws<NotSupportedException>(() => Path.GetFullPath(path));
}
}
[ActiveIssue(27269)]
[PlatformSpecific(TestPlatforms.Windows)] // Tests Windows-specific invalid paths
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
[Theory]
[InlineData("http://www.microsoft.com")]
[InlineData("file://www.microsoft.com")]
public static void GetFullPath_Windows_URIFormatNotSupported_Core(string path)
{
// Throws via our invalid colon filtering
if (!PathFeatures.IsUsingLegacyPathNormalization())
@ -1015,14 +1031,27 @@ namespace System.IO.Tests
}
[PlatformSpecific(TestPlatforms.Windows)] // Tests Windows-specific invalid paths
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
[Theory]
[InlineData('*')]
[InlineData('?')]
public static void GetFullPath_Windows_Wildcards(char wildcard)
public static void GetFullPath_Windows_Wildcards_Desktop(char wildcard)
{
AssertExtensions.Throws<ArgumentException>("path", null, () => Path.GetFullPath("test" + wildcard + "ing"));
}
[ActiveIssue(27269)]
[PlatformSpecific(TestPlatforms.Windows)] // Tests Windows-specific invalid paths
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
[Theory]
[InlineData('*')]
[InlineData('?')]
public static void GetFullPath_Windows_Wildcards_Core(char wildcard)
{
string path = "test" + wildcard + "ing";
Assert.Equal(path, Path.GetFullPath(path));
}
// Windows-only P/Invoke to create 8.3 short names from long names
[DllImport("kernel32.dll", EntryPoint = "GetShortPathNameW" ,CharSet = CharSet.Unicode)]
private static extern uint GetShortPathName(string lpszLongPath, StringBuilder lpszShortPath, int cchBuffer);