Imported Upstream version 5.8.0.22

Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-10-19 20:04:20 +00:00
parent 5f4a27cc8a
commit 7d05485754
5020 changed files with 114082 additions and 186061 deletions

View File

@@ -1 +1 @@
49bee6ad5e4b2381f02bb718fac47fdd08ab822c
75097df175d066a977d4123419651e7561af14a9

View File

@@ -10,9 +10,6 @@
<Compile Include="UriRelativeResolutionTest.cs" />
<Compile Include="UriTests.cs" />
<!-- Test common -->
<Compile Include="$(CommonTestPath)\System\AssertExtensions.cs">
<Link>Common\System\AssertExtensions.cs</Link>
</Compile>
<Compile Include="$(CommonTestPath)\System\ThreadCultureChange.cs">
<Link>Common\System\ThreadCultureChange.cs</Link>
</Compile>

View File

@@ -237,7 +237,7 @@ namespace System.PrivateUri.Tests
[Fact]
public static void TestHexMethods_Invalid()
{
Assert.Throws<ArgumentException>(() => Uri.FromHex('?'));
AssertExtensions.Throws<ArgumentException>(null, () => Uri.FromHex('?'));
Assert.Throws<ArgumentOutOfRangeException>(() => Uri.HexEscape('\x100'));
int index = -1;
Assert.Throws<ArgumentOutOfRangeException>(() => Uri.HexUnescape("%75", ref index));

View File

@@ -73,7 +73,7 @@ namespace System.PrivateUri.Tests
public void IriRelativeResolution_CompareImplcitAndExplicitUncWithNoUnicode_AllPropertiesTheSame()
{
string nonUnicodeImplicitTestUnc = @"\\c\path\path3\test.txt";
string nonUnicodeImplicitUncBase = @"\\c\path\file.txt";
string nonUnicodeImplicitUncBase = @"\\c/path/file.txt";
string testResults;
int errorCount = RelatavizeRestoreCompareImplicitVsExplicitFiles(nonUnicodeImplicitTestUnc,
@@ -120,7 +120,6 @@ namespace System.PrivateUri.Tests
Uri rel = implicitBaseUri.MakeRelativeUri(implicitTestUri);
Uri implicitResultUri = new Uri(implicitBaseUri, rel);
Uri explicitResultUri = new Uri(explicitBaseUri, rel);
Type uriType = typeof(Uri);
PropertyInfo[] infoList = uriType.GetProperties();
StringBuilder testResults = new StringBuilder();

View File

@@ -27,9 +27,6 @@
<Compile Include="UriTests.cs" />
<Compile Include="WebSocketsUriParserTest.cs" />
<!-- Test common -->
<Compile Include="$(CommonTestPath)\System\AssertExtensions.cs">
<Link>Common\System\AssertExtensions.cs</Link>
</Compile>
<Compile Include="$(CommonTestPath)\System\ThreadCultureChange.cs">
<Link>Common\System\ThreadCultureChange.cs</Link>
</Compile>

View File

@@ -167,7 +167,7 @@ namespace System.PrivateUri.Tests
[InlineData("fragment?fragment")]
public void Ctor_InvalidExtraValue_ThrowsArgumentException(string extraValue)
{
Assert.Throws<ArgumentException>(() => new UriBuilder("scheme", "host", 80, "path", extraValue));
AssertExtensions.Throws<ArgumentException>("extraValue", null, () => new UriBuilder("scheme", "host", 80, "path", extraValue));
}
[Theory]
@@ -187,12 +187,12 @@ namespace System.PrivateUri.Tests
[InlineData("-")]
public void InvalidScheme_ThrowsArgumentException(string schemeName)
{
Assert.Throws<ArgumentException>(() => new UriBuilder(schemeName, "host"));
Assert.Throws<ArgumentException>(() => new UriBuilder(schemeName, "host", 80));
Assert.Throws<ArgumentException>(() => new UriBuilder(schemeName, "host", 80, "path"));
Assert.Throws<ArgumentException>(() => new UriBuilder(schemeName, "host", 80, "?query#fragment"));
AssertExtensions.Throws<ArgumentException>("value", null, () => new UriBuilder(schemeName, "host"));
AssertExtensions.Throws<ArgumentException>("value", null, () => new UriBuilder(schemeName, "host", 80));
AssertExtensions.Throws<ArgumentException>("value", null, () => new UriBuilder(schemeName, "host", 80, "path"));
AssertExtensions.Throws<ArgumentException>("value", null, () => new UriBuilder(schemeName, "host", 80, "?query#fragment"));
Assert.Throws<ArgumentException>(() => new UriBuilder().Scheme = schemeName);
AssertExtensions.Throws<ArgumentException>("value", null, () => new UriBuilder().Scheme = schemeName);
}
[Theory]

View File

@@ -2,12 +2,45 @@
// 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.Collections.Generic;
using Xunit;
namespace System.PrivateUri.Tests
{
public static class UriTests
{
public static IEnumerable<object[]> Uri_TestData
{
get
{
if (PlatformDetection.IsWindows)
{
yield return new object[] { @"file:///path1\path2/path3\path4", @"/path1/path2/path3/path4", @"/path1/path2/path3/path4", @"file:///path1/path2/path3/path4", "" };
yield return new object[] { @"file:///path1%5Cpath2\path3", @"/path1/path2/path3", @"/path1/path2/path3", @"file:///path1/path2/path3", ""};
yield return new object[] { @"file://localhost/path1\path2/path3\path4\", @"/path1/path2/path3/path4/", @"\\localhost\path1\path2\path3\path4\", @"file://localhost/path1/path2/path3/path4/", "localhost"};
yield return new object[] { @"file://randomhost/path1%5Cpath2\path3", @"/path1/path2/path3", @"\\randomhost\path1\path2\path3", @"file://randomhost/path1/path2/path3", "randomhost"};
}
else
{
yield return new object[] { @"file:///path1\path2/path3\path4", @"/path1%5Cpath2/path3%5Cpath4", @"/path1\path2/path3\path4", @"file:///path1%5Cpath2/path3%5Cpath4", "" };
yield return new object[] { @"file:///path1%5Cpath2\path3", @"/path1%5Cpath2%5Cpath3", @"/path1\path2\path3", @"file:///path1%5Cpath2%5Cpath3", ""};
yield return new object[] { @"file://localhost/path1\path2/path3\path4\", @"/path1%5Cpath2/path3%5Cpath4%5C", @"\\localhost\path1\path2\path3\path4\", @"file://localhost/path1%5Cpath2/path3%5Cpath4%5C", "localhost"};
yield return new object[] { @"file://randomhost/path1%5Cpath2\path3", @"/path1%5Cpath2%5Cpath3", @"\\randomhost\path1\path2\path3", @"file://randomhost/path1%5Cpath2%5Cpath3", "randomhost"};
}
}
}
[Theory]
[MemberData(nameof(Uri_TestData))]
public static void TestCtor_BackwardSlashInPath(string uri, string expectedAbsolutePath, string expectedLocalPath, string expectedAbsoluteUri, string expectedHost)
{
Uri actualUri = new Uri(uri);
Assert.Equal(expectedAbsolutePath, actualUri.AbsolutePath);
Assert.Equal(expectedLocalPath, actualUri.LocalPath);
Assert.Equal(expectedAbsoluteUri, actualUri.AbsoluteUri);
Assert.Equal(expectedHost, actualUri.Host);
}
[Fact]
public static void TestCtor_String()
{