Add assert when dllmap is disabled and fix support build in netcore mode
[mono-project.git] / mono / tests / assembly-load-bytes.cs
blob729e005e7a46e872801b36911754e9bf16a0e3d3
1 using System;
2 using System.IO;
3 using System.Reflection;
5 public class TestAssemblyLoad {
7 public static int Main ()
9 return TestDriver.RunTests (typeof (TestAssemblyLoad));
12 public static int test_0_LoadBytesSameAssemblyName ()
15 string path1 = Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "assembly-load-dir1", "Lib.dll");
16 string path2 = Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "assembly-load-dir2", "Lib.dll");
17 byte[] bytes1 = File.ReadAllBytes (path1);
18 byte[] bytes2 = File.ReadAllBytes (path2);
20 Assembly asm1 = Assembly.Load (bytes1);
21 Assembly asm2 = Assembly.Load (bytes2);
22 if (asm1 == asm2) {
23 Console.Error.WriteLine ("expected asm1 {0} and asm2 {1} to be different", asm1, asm2);
24 return 1;
27 Type t1 = asm1.GetType ("LibClass");
28 Type t2 = asm2.GetType ("LibClass");
29 if (t1 == t2) {
30 Console.Error.WriteLine ("expected t1 {0} and t2 {1} to be different", t1, t2);
31 return 2;
34 object o1 = Activator.CreateInstance (t1);
35 object o2 = Activator.CreateInstance (t2);
37 string s1 = o1.ToString ();
38 string s2 = o2.ToString ();
40 if (s1 == s2) {
41 Console.Error.WriteLine ("expected string s1 {0} and s2 {1} to be different", s1, s2);
42 return 3;
45 return 0;