提交 f8069034 编写于 作者: S Stephen A. Imhoff 提交者: Stephen Toub

Change expected behavior for reported parameter names


Commit migrated from https://github.com/dotnet/corefx/commit/1988b496ab2434210440526c832354773d653ddf
上级 f6c2208f
......@@ -12,7 +12,7 @@ public static class RuntimeDetection
private static readonly string s_frameworkDescription = RuntimeInformation.FrameworkDescription;
// public static bool IsMono { get; } = Type.GetType("Mono.Runtime") != null;
// public static bool IsNetFramework { get; } = s_frameworkDescription.StartsWith(".NET Framework");
public static bool IsNetFramework { get; } = s_frameworkDescription.StartsWith(".NET Framework");
// public static bool IsCoreclr { get; } = s_frameworkDescription.StartsWith(".NET Core");
public static bool IsNetNative { get; } = s_frameworkDescription.StartsWith(".NET Native");
}
......
......@@ -124,6 +124,9 @@
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
<Link>Common\System\PlatformDetection.cs</Link>
</Compile>
<Compile Include="$(CommonTestPath)\System\RuntimeDetection.cs">
<Link>Common\System\RuntimeDetection.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp1.1'">
<Compile Include="System\ArrayTests.netcoreapp1.1.cs" />
......
......@@ -628,10 +628,13 @@ public static void Append_CharArray_Invalid()
Assert.Throws<ArgumentNullException>("value", () => builder.Append((char[])null, 1, 1)); // Value is null, startIndex > 0 and count > 0
Assert.Throws<ArgumentOutOfRangeException>("startIndex", () => builder.Append(new char[0], -1, 0)); // Start index < 0
Assert.Throws<ArgumentOutOfRangeException>("count", () => builder.Append(new char[0], 0, -1)); // Count < 0
Assert.Throws<ArgumentOutOfRangeException>(
RuntimeDetection.IsNetFramework ? "count" : "charCount", () => builder.Append(new char[0], 0, -1)); // Count < 0
Assert.Throws<ArgumentOutOfRangeException>("count", () => builder.Append(new char[5], 6, 0)); // Start index + count > value.Length
Assert.Throws<ArgumentOutOfRangeException>("count", () => builder.Append(new char[5], 5, 1)); // Start index + count > value.Length
Assert.Throws<ArgumentOutOfRangeException>(
RuntimeDetection.IsNetFramework ? "count" : "charCount", () => builder.Append(new char[5], 6, 0)); // Start index + count > value.Length
Assert.Throws<ArgumentOutOfRangeException>(
RuntimeDetection.IsNetFramework ? "count" : "charCount", () => builder.Append(new char[5], 5, 1)); // Start index + count > value.Length
Assert.Throws<ArgumentOutOfRangeException>("valueCount", () => builder.Append(new char[] { 'a' })); // New length > builder.MaxCapacity
Assert.Throws<ArgumentOutOfRangeException>("valueCount", () => builder.Append(new char[] { 'a' }, 0, 1)); // New length > builder.MaxCapacity
......@@ -1392,9 +1395,9 @@ public static void Insert_CharArray_Invalid()
Assert.Throws<ArgumentOutOfRangeException>("index", () => builder.Insert(builder.Length + 1, new char[0], 0, 0)); // Index > builder.Length
Assert.Throws<ArgumentNullException>(() => builder.Insert(0, null, 1, 1)); // Value is null (startIndex and count are not zero)
Assert.Throws<ArgumentOutOfRangeException>(RuntimeDetection.IsNetFramework ? "count" : "charCount", () => builder.Insert(0, new char[0], 0, -1)); // Char count < 0
Assert.Throws<ArgumentOutOfRangeException>("startIndex", () => builder.Insert(0, new char[0], -1, 0)); // Start index < 0
Assert.Throws<ArgumentOutOfRangeException>("count", () => builder.Insert(0, new char[0], 0, -1)); // Char count < 0
Assert.Throws<ArgumentOutOfRangeException>("startIndex", () => builder.Insert(0, new char[3], 4, 0)); // Start index + char count > value.Length
Assert.Throws<ArgumentOutOfRangeException>("startIndex", () => builder.Insert(0, new char[3], 3, 1)); // Start index + char count > value.Length
......@@ -1436,10 +1439,12 @@ public static void Remove_Invalid()
var builder = new StringBuilder("Hello");
Assert.Throws<ArgumentOutOfRangeException>("startIndex", () => builder.Remove(-1, 0)); // Start index < 0
Assert.Throws<ArgumentOutOfRangeException>("length", () => builder.Remove(0, -1)); // Length < 0
Assert.Throws<ArgumentOutOfRangeException>("index", () => builder.Remove(6, 0)); // Start index + length > 0
Assert.Throws<ArgumentOutOfRangeException>("index", () => builder.Remove(5, 1)); // Start index + length > 0
Assert.Throws<ArgumentOutOfRangeException>("index", () => builder.Remove(4, 2)); // Start index + length > 0
Assert.Throws<ArgumentOutOfRangeException>(
RuntimeDetection.IsNetFramework ? "index" : "length", () => builder.Remove(6, 0)); // Start index + length > 0
Assert.Throws<ArgumentOutOfRangeException>(
RuntimeDetection.IsNetFramework ? "index" : "length", () => builder.Remove(5, 1)); // Start index + length > 0
Assert.Throws<ArgumentOutOfRangeException>(
RuntimeDetection.IsNetFramework ? "index" : "length", () => builder.Remove(4, 2)); // Start index + length > 0
}
[Theory]
......
......@@ -54,7 +54,8 @@ public void CreateFallbackBuffer_Fallback_InvalidSurrogateChars_ThrowsArgumentOu
EncoderFallbackBuffer buffer = new EncoderExceptionFallback().CreateFallbackBuffer();
Assert.Throws<ArgumentOutOfRangeException>("charUnknownHigh", () => buffer.Fallback('a', '\uDC00', 0));
Assert.Throws<ArgumentOutOfRangeException>("CharUnknownLow", () => buffer.Fallback('\uD800', 'a', 0));
Assert.Throws<ArgumentOutOfRangeException>(
RuntimeDetection.IsNetFramework ? "CharUnknownLow" : "charUnknownLow", () => buffer.Fallback('\uD800', 'a', 0));
}
}
}
......@@ -109,7 +109,8 @@ public void CreateFallbackBuffer_Fallback_InvalidSurrogateChars_ThrowsArgumentOu
EncoderFallbackBuffer buffer = new EncoderReplacementFallback().CreateFallbackBuffer();
Assert.Throws<ArgumentOutOfRangeException>("charUnknownHigh", () => buffer.Fallback('a', '\uDC00', 0));
Assert.Throws<ArgumentOutOfRangeException>("CharUnknownLow", () => buffer.Fallback('\uD800', 'a', 0));
Assert.Throws<ArgumentOutOfRangeException>(
RuntimeDetection.IsNetFramework ? "CharUnknownLow" : "charUnknownLow", () => buffer.Fallback('\uD800', 'a', 0));
}
}
}
......@@ -93,5 +93,10 @@
<Name>System.Runtime</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="$(CommonTestPath)\System\RuntimeDetection.cs">
<Link>Common\System\RuntimeDetection.cs</Link>
</Compile>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册