未验证 提交 50011577 编写于 作者: M Michal Strehovský 提交者: GitHub

Gate enum tests that depend on Ref.Emit (#50093)

In #49925 I blindly followed the existing pattern but the existing pattern was wrong because with that we get failing tests:

```
System.InvalidOperationException : No data found for System.Tests.EnumTests.IsDefined_UnsupportedEnumType_ThrowsInvalidOperationException
```
上级 f690d59f
......@@ -1979,23 +1979,20 @@ public static void Format_Invalid()
public static IEnumerable<object[]> UnsupportedEnumType_TestData()
{
if (PlatformDetection.IsReflectionEmitSupported)
{
yield return new object[] { s_floatEnumType, 1.0f };
yield return new object[] { s_doubleEnumType, 1.0 };
yield return new object[] { s_intPtrEnumType, (IntPtr)1 };
yield return new object[] { s_uintPtrEnumType, (UIntPtr)1 };
}
yield return new object[] { s_floatEnumType, 1.0f };
yield return new object[] { s_doubleEnumType, 1.0 };
yield return new object[] { s_intPtrEnumType, (IntPtr)1 };
yield return new object[] { s_uintPtrEnumType, (UIntPtr)1 };
}
[Theory]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
[MemberData(nameof(UnsupportedEnumType_TestData))]
public static void GetName_Unsupported_ThrowsArgumentException(Type enumType, object value)
{
AssertExtensions.Throws<ArgumentException>("value", () => Enum.GetName(enumType, value));
}
[Theory]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
[MemberData(nameof(UnsupportedEnumType_TestData))]
public static void IsDefined_UnsupportedEnumType_ThrowsInvalidOperationException(Type enumType, object value)
{
......@@ -2006,16 +2003,13 @@ public static void IsDefined_UnsupportedEnumType_ThrowsInvalidOperationException
public static IEnumerable<object[]> UnsupportedEnum_TestData()
{
if (PlatformDetection.IsReflectionEmitSupported)
{
yield return new object[] { Enum.ToObject(s_floatEnumType, 1) };
yield return new object[] { Enum.ToObject(s_doubleEnumType, 2) };
yield return new object[] { Enum.ToObject(s_intPtrEnumType, 1) };
yield return new object[] { Enum.ToObject(s_uintPtrEnumType, 2) };
}
yield return new object[] { Enum.ToObject(s_floatEnumType, 1) };
yield return new object[] { Enum.ToObject(s_doubleEnumType, 2) };
yield return new object[] { Enum.ToObject(s_intPtrEnumType, 1) };
yield return new object[] { Enum.ToObject(s_uintPtrEnumType, 2) };
}
[Theory]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
[MemberData(nameof(UnsupportedEnum_TestData))]
public static void ToString_UnsupportedEnumType_ThrowsArgumentException(Enum e)
{
......@@ -2024,7 +2018,7 @@ public static void ToString_UnsupportedEnumType_ThrowsArgumentException(Enum e)
Assert.True(formatXExceptionName == nameof(InvalidOperationException) || formatXExceptionName == "ContractException");
}
[Theory]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
[MemberData(nameof(UnsupportedEnumType_TestData))]
public static void Format_UnsupportedEnumType_ThrowsArgumentException(Type enumType, object value)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册