New test.
[mono.git] / mono / tests / cas / linkdemand / refcas1.cs
1 using System;
2 using System.Reflection;
3 using System.Security;
4 using System.Security.Permissions;
5
6 public class Program {
7
8         [SecurityPermission (SecurityAction.LinkDemand, ControlPrincipal=true)]
9         public static int Test ()
10         {
11                 return 0;
12         }
13
14         static int TestReflectedCall ()
15         {
16                 MethodInfo mi = typeof (Program).GetMethod ("Test", BindingFlags.Static | BindingFlags.Public);
17                 if (mi == null) {
18                         Console.WriteLine ("*1* Couldn't reflect on call Test");
19                         return 1;
20                 }
21                 return (int) mi.Invoke (null, null);
22         }
23
24         static int Main ()
25         {
26                 try {
27                         int result = TestReflectedCall ();
28                         if (result == 0)
29                                 Console.WriteLine ("*0* Could reflection on method (normal).");
30                         return result;
31                 }
32                 catch (SecurityException se) {
33                         Console.WriteLine ("*2* Unexpected SecurityException.\n{0}", se);
34                         return 2;
35                 }
36                 catch (Exception e) {
37                         Console.WriteLine ("*3* Unexpected Exception.\n{0}", e);
38                         return 3;
39                 }
40         }
41 }