* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / corlib / Test / System.Reflection / AssemblyTest.cs
1 //
2 // System.Reflection.Assembly Test Cases
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //      Philippe Lavoie (philippe.lavoie@cactus.ca)
7 //      Sebastien Pouliot (sebastien@ximian.com)
8 //
9 // (c) 2003 Ximian, Inc. (http://www.ximian.com)
10 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 // 
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 // 
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //
31
32 using NUnit.Framework;
33 using System;
34 using System.Configuration.Assemblies;
35 using System.Globalization;
36 using System.IO;
37 using System.Reflection;
38 using System.Reflection.Emit;
39 using System.Runtime.Serialization;
40 using System.Security;
41
42 namespace MonoTests.System.Reflection
43 {
44         [TestFixture]
45         public class AssemblyTest
46         {
47                 [Test] 
48                 public void CreateInstance() 
49                 {
50                         Type type = typeof (AssemblyTest);
51                         Object obj = type.Assembly.CreateInstance ("MonoTests.System.Reflection.AssemblyTest");
52                         Assert.IsNotNull (obj, "#01");
53                         Assert.AreEqual (GetType (), obj.GetType (), "#02");
54                 }
55
56                 [Test] 
57                 public void CreateInvalidInstance() 
58                 {
59                         Type type = typeof (AssemblyTest);
60                         Object obj = type.Assembly.CreateInstance("NunitTests.ThisTypeDoesNotExist");
61                         Assert.IsNull (obj, "#03");
62                 }
63
64                 [Test]
65 #if NET_2_0
66                 [Category ("NotWorking")]
67                 [ExpectedException (typeof (ArgumentException))]
68 #else
69                 [ExpectedException (typeof (TypeLoadException))]
70 #endif
71                 public void TestGetType () 
72                 {
73                         // Bug #49114
74                         typeof (int).Assembly.GetType ("&blabla", true, true);
75                 }
76
77                 [Test]
78                 public void GetEntryAssembly ()
79                 {
80                         // note: only available in default appdomain
81                         // http://weblogs.asp.net/asanto/archive/2003/09/08/26710.aspx
82                         // Not sure we should emulate this behavior.
83                         string fname = AppDomain.CurrentDomain.FriendlyName;
84                         if (fname.EndsWith (".dll")) { // nunit-console
85                                 Assert.IsNull (Assembly.GetEntryAssembly (), "GetEntryAssembly");
86 #if NET_2_0
87                                 Assert.IsFalse (AppDomain.CurrentDomain.IsDefaultAppDomain (), "!default appdomain");
88 #endif
89                         } else { // gnunit
90                                 Assert.IsNotNull (Assembly.GetEntryAssembly (), "GetEntryAssembly");
91 #if NET_2_0
92                                 Assert.IsTrue (AppDomain.CurrentDomain.IsDefaultAppDomain (), "!default appdomain");
93 #endif
94                         }
95                 }
96 #if NET_2_0
97                 [Category ("NotWorking")]
98 #endif
99                 [Test]
100                 public void Corlib () 
101                 {
102                         Assembly corlib = typeof (int).Assembly;
103                         Assert.IsTrue (corlib.CodeBase.EndsWith ("mscorlib.dll"), "CodeBase");
104                         Assert.IsNull (corlib.EntryPoint, "EntryPoint");
105                         Assert.IsTrue (corlib.EscapedCodeBase.EndsWith ("mscorlib.dll"), "EscapedCodeBase");
106                         Assert.IsNotNull (corlib.Evidence, "Evidence");
107                         Assert.IsTrue (corlib.Location.EndsWith ("mscorlib.dll"), "Location");
108
109                         // corlib doesn't reference anything
110                         Assert.AreEqual (0, corlib.GetReferencedAssemblies ().Length, "GetReferencedAssemblies");
111 #if NET_2_0
112                         Assert.AreEqual ("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", corlib.FullName, "FullName");
113                         // not really "true" but it's even more trusted so...
114                         Assert.IsTrue (corlib.GlobalAssemblyCache, "GlobalAssemblyCache");
115                         Assert.AreEqual (0, corlib.HostContext, "HostContext");
116                         Assert.AreEqual ("v2.0.50727", corlib.ImageRuntimeVersion, "ImageRuntimeVersion");
117                         Assert.IsFalse (corlib.ReflectionOnly, "ReflectionOnly");
118                         Assert.AreEqual (0x1, corlib.ManifestModule.MetadataToken);
119 #elif NET_1_1
120                         Assert.IsFalse (corlib.GlobalAssemblyCache, "GlobalAssemblyCache");
121                         Assert.AreEqual ("mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", corlib.FullName, "FullName");
122                         Assert.AreEqual ("v1.1.4322", corlib.ImageRuntimeVersion, "ImageRuntimeVersion");
123 #endif
124                 }
125
126                 [Test]
127                 public void Corlib_test ()
128                 {
129                         Assembly corlib_test = Assembly.GetExecutingAssembly ();
130                         Assert.IsNull (corlib_test.EntryPoint, "EntryPoint");
131                         Assert.IsNotNull (corlib_test.Evidence, "Evidence");
132                         Assert.IsFalse (corlib_test.GlobalAssemblyCache, "GlobalAssemblyCache");
133
134                         Assert.IsTrue (corlib_test.GetReferencedAssemblies ().Length > 0, "GetReferencedAssemblies");
135 #if NET_2_0
136                         Assert.AreEqual (0, corlib_test.HostContext, "HostContext");
137                         Assert.AreEqual ("v2.0.50727", corlib_test.ImageRuntimeVersion, "ImageRuntimeVersion");
138                         Assert.IsNotNull (corlib_test.ManifestModule, "ManifestModule");
139                         Assert.IsFalse (corlib_test.ReflectionOnly, "ReflectionOnly");
140 #elif NET_1_1
141                         Assert.AreEqual ("v1.1.4322", corlib_test.ImageRuntimeVersion, "ImageRuntimeVersion");
142 #endif
143                 }
144
145                 [Test]
146                 public void GetAssembly ()
147                 {
148                         Assert.IsTrue (Assembly.GetAssembly (typeof (int)).FullName.StartsWith ("mscorlib"), "GetAssembly(int)");
149                         Assert.AreEqual (this.GetType ().Assembly.FullName, Assembly.GetAssembly (this.GetType ()).FullName, "GetAssembly(this)");
150                 }
151
152                 [Test]
153                 [ExpectedException (typeof (ArgumentNullException))]
154                 public void GetFile_Null ()
155                 {
156                         Assembly.GetExecutingAssembly ().GetFile (null);
157                 }
158
159                 [Test]
160                 [ExpectedException (typeof (ArgumentException))]
161                 public void GetFile_Empty ()
162                 {
163                         Assembly.GetExecutingAssembly ().GetFile (String.Empty);
164                 }
165
166                 [Test]
167                 public void GetFiles_False ()
168                 {
169                         Assembly corlib = typeof (int).Assembly;
170                         FileStream[] fss = corlib.GetFiles ();
171                         Assert.AreEqual (fss.Length, corlib.GetFiles (false).Length, "corlib.GetFiles (false)");
172
173                         Assembly corlib_test = Assembly.GetExecutingAssembly ();
174                         fss = corlib_test.GetFiles ();
175                         Assert.AreEqual (fss.Length, corlib_test.GetFiles (false).Length, "test.GetFiles (false)");
176                 }
177
178                 [Test]
179                 public void GetFiles_True ()
180                 {
181                         Assembly corlib = typeof (int).Assembly;
182                         FileStream[] fss = corlib.GetFiles ();
183                         Assert.IsTrue (fss.Length <= corlib.GetFiles (true).Length, "corlib.GetFiles (true)");
184
185                         Assembly corlib_test = Assembly.GetExecutingAssembly ();
186                         fss = corlib_test.GetFiles ();
187                         Assert.IsTrue (fss.Length <= corlib_test.GetFiles (true).Length, "test.GetFiles (true)");
188                 }
189
190                 [Test] // bug #78517
191 #if ONLY_1_1
192                 [Category ("NotDotNet")] // MS.NET 1.x throws FileLoadException
193 #endif
194                 public void LoadFrom_Empty_Assembly ()
195                 {
196                         string tempFile = Path.GetTempFileName ();
197
198                         try {
199                                 Assembly.LoadFrom (tempFile);
200                                 Assert.Fail ("#1");
201                         } catch (BadImageFormatException ex) {
202                                 Assert.IsNull (ex.InnerException, "#2");
203                         } finally {
204                                 File.Delete (tempFile);
205                         }
206                 }
207
208                 [Test] // bug #78517
209                 public void LoadFrom_Invalid_Assembly ()
210                 {
211                         string tempFile = Path.GetTempFileName ();
212                         using (StreamWriter sw = File.CreateText (tempFile)) {
213                                 sw.WriteLine ("foo");
214                                 sw.Close ();
215                         }
216
217                         try {
218                                 Assembly.LoadFrom (tempFile);
219                                 Assert.Fail ("#1");
220                         } catch (BadImageFormatException ex) {
221                                 Assert.IsNull (ex.InnerException, "#2");
222                         } finally {
223                                 File.Delete (tempFile);
224                         }
225                 }
226
227                 [Test]
228                 public void LoadFrom_NonExisting_Assembly ()
229                 {
230                         string tempFile = Path.GetTempFileName ();
231                         File.Delete (tempFile);
232
233                         try {
234                                 Assembly.LoadFrom (tempFile);
235                                 Assert.Fail ("#1");
236                         } catch (FileNotFoundException ex) {
237                                 Assert.IsNull (ex.InnerException, "#2");
238                         } finally {
239                                 File.Delete (tempFile);
240                         }
241                 }
242
243                 [Test]
244                 public void LoadWithPartialName ()
245                 {
246                         string [] names = { "corlib_test_default", "corlib_test_net_2_0", "corlib_plattest" };
247
248                         foreach (string s in names)
249                                 if (Assembly.LoadWithPartialName (s) != null)
250                                         return;
251                         Assertion.Fail ("Was not able to load any corlib test");
252                 }
253
254                 [Test]
255                 [ExpectedException (typeof (ArgumentNullException))]
256                 public void GetObjectData_Null ()
257                 {
258                         Assembly corlib = typeof (int).Assembly;
259                         corlib.GetObjectData (null, new StreamingContext (StreamingContextStates.All));
260                 }
261
262                 [Test]
263                 public void GetReferencedAssemblies ()
264                 {
265                         Assembly corlib_test = Assembly.GetExecutingAssembly ();
266                         AssemblyName[] names = corlib_test.GetReferencedAssemblies ();
267                         foreach (AssemblyName an in names) {
268                                 Assert.IsNull (an.CodeBase, "CodeBase");
269                                 Assert.IsNotNull (an.CultureInfo, "CultureInfo");
270                                 Assert.IsNull (an.EscapedCodeBase, "EscapedCodeBase");
271                                 Assert.AreEqual (AssemblyNameFlags.None, an.Flags, "Flags");
272                                 Assert.IsNotNull (an.FullName, "FullName");
273                                 Assert.AreEqual (AssemblyHashAlgorithm.SHA1, an.HashAlgorithm, "HashAlgorithm");
274                                 Assert.IsNull (an.KeyPair, "KeyPair");
275                                 Assert.IsNotNull (an.Name, "Name");
276                                 Assert.IsNotNull (an.Version, "Version");
277                                 Assert.AreEqual (AssemblyVersionCompatibility.SameMachine, 
278                                         an.VersionCompatibility, "VersionCompatibility");
279                         }
280                 }
281
282                 [Test]
283                 public void Location_Empty() {
284                         string assemblyFileName = Path.Combine (
285                                 Path.GetTempPath (), "AssemblyLocation.dll");
286
287                         try {
288                                 AssemblyName assemblyName = new AssemblyName ();
289                                 assemblyName.Name = "AssemblyLocation";
290
291                                 AssemblyBuilder ab = AppDomain.CurrentDomain
292                                         .DefineDynamicAssembly (assemblyName,
293                                         AssemblyBuilderAccess.Save,
294                                         Path.GetTempPath (),
295                                         AppDomain.CurrentDomain.Evidence);
296                                 ab.Save (Path.GetFileName (assemblyFileName));
297
298                                 using (FileStream fs = File.OpenRead (assemblyFileName)) {
299                                         byte[] buffer = new byte[fs.Length];
300                                         fs.Read (buffer, 0, buffer.Length);
301                                         Assembly assembly = Assembly.Load (buffer);
302                                         Assert.AreEqual (string.Empty, assembly.Location);
303                                         fs.Close ();
304                                 }
305                         } finally {
306                                 File.Delete (assemblyFileName);
307                         }
308                 }
309
310                 [Test]
311                 [Category ("NotWorking")]
312                 public void bug78464 ()
313                 {
314                         string assemblyFileName = Path.Combine (
315                                 Path.GetTempPath (), "bug78464.dll");
316
317                         try {
318                                 // execute test in separate appdomain to allow assembly to be unloaded
319                                 AppDomain testDomain = CreateTestDomain ();
320                                 CrossDomainTester crossDomainTester = CreateCrossDomainTester (testDomain);
321                                 try {
322                                         crossDomainTester.bug78464 (assemblyFileName);
323                                 } finally {
324                                         AppDomain.Unload (testDomain);
325                                 }
326                         } finally {
327                                 File.Delete (assemblyFileName);
328                         }
329                 }
330
331                 [Test]
332                 [Category ("NotWorking")]
333                 public void bug78465 ()
334                 {
335                         string assemblyFileName = Path.Combine (
336                                 Path.GetTempPath (), "bug78465.dll");
337
338                         try {
339                                 AssemblyName assemblyName = new AssemblyName ();
340                                 assemblyName.Name = "bug78465";
341
342                                 AssemblyBuilder ab = AppDomain.CurrentDomain
343                                         .DefineDynamicAssembly (assemblyName,
344                                         AssemblyBuilderAccess.Save,
345                                         Path.GetDirectoryName (assemblyFileName),
346                                         AppDomain.CurrentDomain.Evidence);
347                                 ab.Save (Path.GetFileName (assemblyFileName));
348
349                                 using (FileStream fs = File.OpenRead (assemblyFileName)) {
350                                         byte[] buffer = new byte[fs.Length];
351                                         fs.Read (buffer, 0, buffer.Length);
352                                         Assembly assembly = Assembly.Load (buffer);
353                                         Assert.AreEqual (string.Empty, assembly.Location, "#1");
354                                         fs.Close ();
355                                 }
356
357                                 AppDomain testDomain = CreateTestDomain ();
358                                 CrossDomainTester crossDomainTester = CreateCrossDomainTester (testDomain);
359                                 try {
360                                         crossDomainTester.bug78465 (assemblyFileName);
361                                 } finally {
362                                         AppDomain.Unload (testDomain);
363                                 }
364                         } finally {
365                                 File.Delete (assemblyFileName);
366                         }
367                 }
368
369                 [Test]
370                 public void bug78468 ()
371                 {
372                         string assemblyFileNameA = Path.Combine (Path.GetTempPath (),
373                                 "bug78468a.dll");
374                         string resourceFileName = Path.Combine (Path.GetTempPath (),
375                                 "readme.txt");
376
377                         using (StreamWriter sw = File.CreateText (resourceFileName)) {
378                                 sw.WriteLine ("FOO");
379                                 sw.Close ();
380                         }
381
382                         try {
383                                 AssemblyName assemblyName = new AssemblyName ();
384                                 assemblyName.Name = "bug78468a";
385
386                                 AssemblyBuilder ab = AppDomain.CurrentDomain
387                                         .DefineDynamicAssembly (assemblyName,
388                                         AssemblyBuilderAccess.Save,
389                                         Path.GetTempPath (),
390                                         AppDomain.CurrentDomain.Evidence);
391                                 ab.AddResourceFile ("read", "readme.txt");
392                                 ab.Save (Path.GetFileName (assemblyFileNameA));
393
394                                 Assembly assembly;
395
396                                 using (FileStream fs = File.OpenRead (assemblyFileNameA)) {
397                                         byte[] buffer = new byte[fs.Length];
398                                         fs.Read (buffer, 0, buffer.Length);
399                                         assembly = Assembly.Load (buffer);
400                                         fs.Close ();
401                                 }
402
403                                 Assert.AreEqual (string.Empty, assembly.Location, "#A1");
404                                 string[] resNames = assembly.GetManifestResourceNames ();
405                                 Assert.IsNotNull (resNames, "#A2");
406                                 Assert.AreEqual (1, resNames.Length, "#A3");
407                                 Assert.AreEqual ("read", resNames[0], "#A4");
408                                 ManifestResourceInfo resInfo = assembly.GetManifestResourceInfo ("read");
409                                 Assert.IsNotNull (resInfo, "#A5");
410                                 Assert.AreEqual ("readme.txt", resInfo.FileName, "#A6");
411                                 Assert.IsNull (resInfo.ReferencedAssembly, "#A7");
412                                 Assert.AreEqual ((ResourceLocation) 0, resInfo.ResourceLocation, "#A8");
413                                 Assert.IsNull (assembly.GetManifestResourceStream ("read"), "#A9");
414                                 try {
415                                         assembly.GetFile ("readme.txt");
416                                         Assert.Fail ("#A10");
417                                 } catch (FileNotFoundException) {
418                                 }
419
420                                 string assemblyFileNameB = Path.Combine (Path.GetTempPath (),
421                                         "bug78468b.dll");
422
423                                 AppDomain testDomain = CreateTestDomain ();
424                                 CrossDomainTester crossDomainTester = CreateCrossDomainTester (testDomain);
425                                 try {
426                                         crossDomainTester.bug78468 (assemblyFileNameB);
427                                 } finally {
428                                         AppDomain.Unload (testDomain);
429                                         File.Delete (assemblyFileNameB);
430                                 }
431                         } finally {
432                                 File.Delete (assemblyFileNameA);
433                                 File.Delete (resourceFileName);
434                         }
435                 }
436
437 #if NET_2_0
438                 [Test]
439                 [Category ("NotWorking")]
440                 public void ReflectionOnlyLoad ()
441                 {
442                         Assembly assembly = Assembly.ReflectionOnlyLoad (typeof (AssemblyTest).Assembly.FullName);
443                         
444                         Assert.IsNotNull (assembly);
445                         Assert.IsTrue (assembly.ReflectionOnly);
446                 }
447
448                 [Test]
449                 public void ReflectionOnlyLoadFrom ()
450                 {
451                         string loc = typeof (AssemblyTest).Assembly.Location;
452                         string filename = Path.GetFileName (loc);
453                         Assembly assembly = Assembly.ReflectionOnlyLoadFrom (filename);
454
455                         Assert.IsNotNull (assembly);
456                         Assert.IsTrue (assembly.ReflectionOnly);
457                 }
458
459                 [Test]
460                 [ExpectedException (typeof (ArgumentException))]
461                 public void CreateInstanceOnRefOnly ()
462                 {
463                         Assembly assembly = Assembly.ReflectionOnlyLoad (typeof (AssemblyTest).Assembly.FullName);
464                         assembly.CreateInstance ("MonoTests.System.Reflection.AssemblyTest");
465                 }
466 #endif
467
468                 private static AppDomain CreateTestDomain ()
469                 {
470                         return AppDomain.CreateDomain ("CompileFromDom", AppDomain.CurrentDomain.Evidence,
471                                 AppDomain.CurrentDomain.SetupInformation);
472                 }
473
474                 private static CrossDomainTester CreateCrossDomainTester (AppDomain domain)
475                 {
476                         Type testerType = typeof (CrossDomainTester);
477
478                         return (CrossDomainTester) domain.CreateInstanceAndUnwrap (
479                                 testerType.Assembly.FullName, testerType.FullName, false,
480                                 BindingFlags.Public | BindingFlags.Instance, null, new object[0],
481                                 CultureInfo.InvariantCulture, new object[0], domain.Evidence);
482                 }
483
484                 private class CrossDomainTester : MarshalByRefObject
485                 {
486                         public void bug78464 (string assemblyFileName)
487                         {
488                                 AssemblyName assemblyName = new AssemblyName ();
489                                 assemblyName.Name = "bug78464";
490
491                                 AssemblyBuilder ab = AppDomain.CurrentDomain
492                                         .DefineDynamicAssembly (assemblyName,
493                                         AssemblyBuilderAccess.Save,
494                                         Path.GetDirectoryName (assemblyFileName),
495                                         AppDomain.CurrentDomain.Evidence);
496                                 ab.Save (Path.GetFileName (assemblyFileName));
497
498                                 Assembly assembly;
499
500                                 using (FileStream fs = File.OpenRead (assemblyFileName)) {
501                                         byte[] buffer = new byte[fs.Length];
502                                         fs.Read (buffer, 0, buffer.Length);
503                                         assembly = Assembly.Load (buffer);
504                                         fs.Close ();
505                                 }
506
507                                 Assert.AreEqual (string.Empty, assembly.Location, "#1");
508
509                                 assembly = Assembly.LoadFrom (assemblyFileName, AppDomain.CurrentDomain.Evidence);
510                                 Assert.IsFalse (assembly.Location == string.Empty, "#2");
511                                 Assert.AreEqual (Path.GetFileName (assemblyFileName), Path.GetFileName(assembly.Location), "#3");
512                                 // note: we cannot check if directory names match, as MS.NET seems to 
513                                 // convert directory part of assembly location to lowercase
514                                 Assert.IsFalse (Path.GetDirectoryName(assembly.Location) == string.Empty, "#4");
515                         }
516
517                         public void bug78465 (string assemblyFileName)
518                         {
519                                 Assembly assembly = Assembly.LoadFrom (assemblyFileName, AppDomain.CurrentDomain.Evidence);
520                                 Assert.IsFalse (assembly.Location == string.Empty, "#2");
521                                 Assert.AreEqual (Path.GetFileName (assemblyFileName), Path.GetFileName (assembly.Location), "#3");
522                                 // note: we cannot check if directory names match, as MS.NET seems to 
523                                 // convert directory part of assembly location to lowercase
524                                 Assert.IsFalse (Path.GetDirectoryName (assembly.Location) == string.Empty, "#4");
525                         }
526
527                         public void bug78468 (string assemblyFileName)
528                         {
529                                 AssemblyName assemblyName = new AssemblyName ();
530                                 assemblyName.Name = "bug78468b";
531
532                                 AssemblyBuilder ab = AppDomain.CurrentDomain
533                                         .DefineDynamicAssembly (assemblyName,
534                                         AssemblyBuilderAccess.Save,
535                                         Path.GetDirectoryName (assemblyFileName),
536                                         AppDomain.CurrentDomain.Evidence);
537                                 ab.AddResourceFile ("read", "readme.txt");
538                                 ab.Save (Path.GetFileName (assemblyFileName));
539
540                                 Assembly assembly = Assembly.LoadFrom (assemblyFileName, AppDomain.CurrentDomain.Evidence);
541                                 Assert.IsTrue (assembly.Location != string.Empty, "#B1");
542                                 string[] resNames = assembly.GetManifestResourceNames ();
543                                 Assert.IsNotNull (resNames, "#B2");
544                                 Assert.AreEqual (1, resNames.Length, "#B3");
545                                 Assert.AreEqual ("read", resNames[0], "#B4");
546                                 ManifestResourceInfo resInfo = assembly.GetManifestResourceInfo ("read");
547                                 Assert.IsNotNull (resInfo, "#B5");
548                                 Assert.AreEqual ("readme.txt", resInfo.FileName, "#B6");
549                                 Assert.IsNull (resInfo.ReferencedAssembly, "#B7");
550                                 Assert.AreEqual ((ResourceLocation) 0, resInfo.ResourceLocation, "#B8");
551                                 Stream s = assembly.GetManifestResourceStream ("read");
552                                 Assert.IsNotNull (s, "#B9");
553                                 s.Close ();
554                                 s = assembly.GetFile ("readme.txt");
555                                 Assert.IsNotNull (s, "#B10");
556                                 s.Close ();
557                         }
558                 }
559         }
560 }