New test.
[mono.git] / mono / tests / cas / inheritance / cas3.cs
1 using System;
2 using System.Reflection;
3 using System.Security;
4 using System.Security.Permissions;
5
6 public interface IProgram {
7
8         [StrongNameIdentityPermission (SecurityAction.InheritanceDemand, PublicKey="0024000004800000940000000602000000240000525341310004000011000000db294bcb78b7361ed6eb5656b612ce266fc81da8c8c6cb04116fc29b5e1d09a02f6c0f387f6d97a1ce9bdbbeb2d874832ae2d2971e70144ea039c710dccab5fb0a36cb14268a83c9b435c1e7318e7915518b68c8ed056b104e76166d6cabe9b77383f26bcf6a0a0b09d04f37b2a407b47d39421a34f2fbc6e6701a1d5c2e8cbb")]
9         int InstanceTest ();
10 }
11
12 public class Program : IProgram {
13
14         static bool IsSigned ()
15         {
16                 AssemblyName an = Assembly.GetExecutingAssembly ().GetName ();
17                 return (an.GetPublicKey () != null);
18         }
19
20         int rc;
21
22         public Program ()
23         {
24                 rc = IsSigned () ? 0 : 1;
25                 Console.WriteLine ("*{0}* AbstractProgram", rc);
26         }
27
28         public int InstanceTest ()
29         {
30                 return rc;
31         }
32
33         static int Test ()
34         {
35                 return new Program ().InstanceTest ();
36         }
37
38         static int Main ()
39         {
40                 try {
41                         return Test ();
42                 }
43                 catch (SecurityException se) {
44                         // if unsigned the SecurityException will be unhandled
45                         Console.WriteLine ("*1* Unexpected SecurityException\n{0}", se);
46                         return 1;
47                 }
48                 catch (Exception e) {
49                         Console.WriteLine ("*2* Unexpected Exception\n{0}", e);
50                         return 2;
51                 }
52         }
53 }