2005-02-08 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mono / tests / cas / linkdemand / cas1.cs
1 using System;
2 using System.Security;
3 using System.Security.Permissions;
4
5 namespace System {
6
7         public class Program {
8
9                 [SecurityPermission (SecurityAction.LinkDemand, Unrestricted=true)]
10                 static void Test ()
11                 {
12                         Console.WriteLine ("[SecurityPermission (SecurityAction.LinkDemand, Unrestricted=true)]");
13                 }
14
15                 static int Main ()
16                 {
17                         IPermission p = (IPermission) new SecurityPermission (PermissionState.Unrestricted);
18                         bool granted = SecurityManager.IsGranted (p);
19                         int retval = 3;
20
21                         try {
22                                 Test ();
23                                 retval = (granted ? 0 : 1);
24                                 Console.WriteLine ("*{0}* LinkDemand", retval);
25                         }
26                         catch (SecurityException se) {
27                                 retval = (granted ? 1 : 0);
28                                 Console.WriteLine ("*{0}* SecurityException\n{1}", retval, se);
29                         }
30                         catch (Exception e) {
31                                 Console.WriteLine ("*2* Unexpected exception\n{0}", e);
32                                 return 2;
33                         }
34
35                         return retval;
36                 }
37         }
38 }