Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / assemblyresolve_event.cs
1 using System;
2 using System.Reflection;
3
4 public class App
5 {
6         static bool[] expected_results = {true, false, false, true};
7         static bool handler_fired;
8         
9         public static int Main ()
10         {
11                 AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler);
12
13                 int i = 0;
14                 handler_fired = false;
15                 
16                 try {
17                         Assembly.Load ("SomeAssembly");
18                 } catch (Exception) {
19                 }
20                 if (expected_results [i] != handler_fired)
21                         return 1;
22
23                 i++;
24                 handler_fired = false;
25                 try {
26                         Assembly.LoadFile ("SomeAssembly");
27                 } catch (Exception) {
28                 }
29                 if (expected_results [i] != handler_fired)
30                         return 2;
31                 
32                 i++;
33                 handler_fired = false;
34                 try {
35                         Assembly.LoadFrom ("SomeAssembly");
36                 } catch (Exception) {
37                 }
38                 if (expected_results [i] != handler_fired)
39                         return 3;
40
41                 i++;
42                 handler_fired = false;
43                 try {
44                         Assembly.LoadWithPartialName ("SomeAssembly");
45                 } catch (Exception) {
46                 }
47                 if (expected_results [i] != handler_fired)
48                         return 4;
49
50                 return 0;
51         }
52
53         static Assembly MyResolveEventHandler(object sender, ResolveEventArgs args) {
54                 handler_fired = true;
55                 return null;
56         }
57 }