-
Notifications
You must be signed in to change notification settings - Fork 659
/
Copy pathTestCLREnum.cs
73 lines (65 loc) · 2.39 KB
/
TestCLREnum.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
namespace TestCases
{
public class TestCLREnum
{
public static string Test00()
{
var str = ILRuntimeTest.TestFramework.TestCLREnum.Test1.ToString();
Console.WriteLine("Test10 : " + str);
if (str == "Test1")
{
return str;
}
throw new Exception("Test Fail");
}
public static string Test01()
{
var str = ILRuntimeTest.TestFramework.TestCLREnum.Test1 + 1;
Console.WriteLine(str);
if (str.ToString() == "Test2")
{
return str.ToString();
}
throw new Exception("Test Fail");
}
enum MyEnum9 { AAA }
public static void Test02()
{
object o = MyEnum9.AAA;
Console.WriteLine(o is MyEnum9); //true
Console.WriteLine(o is Enum); //false should be true
}
public static void Test03()
{
Console.WriteLine(new List<object>() { MyEnum9.AAA }.Contains((MyEnum9)123)); //should be true,because two items are ilenuminstancetype
}
public static void Test04()
{
Console.WriteLine(MyEnum9.AAA.GetType());//shouild be Enum20
}
public static void Test05()
{
Dictionary<object, object> dict = new Dictionary<object, object>() { { MyEnum9.AAA, MyEnum9.AAA } };
Console.WriteLine(dict.ContainsKey(MyEnum9.AAA)); //false, should be true
Console.WriteLine(dict.ContainsValue(MyEnum9.AAA));
}
static ILRuntimeTest.TestFramework.TestCLREnum clrEnumTestField = ILRuntimeTest.TestFramework.TestCLREnum.Test2;
public static void Test06()
{
var res = ILRuntimeTest.TestFramework.TestCLREnumClass.Test == ILRuntimeTest.TestFramework.TestCLREnum.Test2;
Console.WriteLine(res);
if (!res)
throw new Exception();
res = ILRuntimeTest.TestFramework.TestCLREnumClass.Test2 == ILRuntimeTest.TestFramework.TestCLREnum.Test3;
Console.WriteLine(res);
if (!res)
throw new Exception();
res = clrEnumTestField == ILRuntimeTest.TestFramework.TestCLREnum.Test2;
Console.WriteLine(res);
if (!res)
throw new Exception();
}
}
}