コード例 #1
0
        public static void GetAssemblies()
        {
            using (TypeLoader tl = new TypeLoader())
            {
                Assembly[] loadedAssemblies = tl.GetAssemblies().ToArray();
                Assert.Equal(0, loadedAssemblies.Length);

                Assembly a1 = tl.LoadFromByteArray(TestData.s_SimpleAssemblyImage);
                Assembly a2 = tl.LoadFromByteArray(TestData.s_SimpleNameOnlyImage);
                loadedAssemblies = tl.GetAssemblies().ToArray();
                Assert.Equal(2, loadedAssemblies.Length);
                Assert.Contains <Assembly>(a1, loadedAssemblies);
                Assert.Contains <Assembly>(a2, loadedAssemblies);
            }
        }
コード例 #2
0
 public static void GetAssemblies_EmptyTypeLoader()
 {
     using (TypeLoader tl = new TypeLoader())
     {
         Assembly[] loadedAssemblies = tl.GetAssemblies().ToArray();
         Assert.Equal(0, loadedAssemblies.Length);
     }
 }
コード例 #3
0
 public static void GetAssemblies_SnapshotIsAtomic()
 {
     using (TypeLoader tl = new TypeLoader())
     {
         Assembly a1 = tl.LoadFromByteArray(TestData.s_SimpleAssemblyImage);
         IEnumerable <Assembly> loadedAssembliesSnapshot = tl.GetAssemblies();
         Assembly   a2 = tl.LoadFromByteArray(TestData.s_SimpleNameOnlyImage);
         Assembly[] loadedAssemblies = loadedAssembliesSnapshot.ToArray();
         Assert.Equal(1, loadedAssemblies.Length);
         Assert.Equal(a1, loadedAssemblies[0]);
     }
 }
コード例 #4
0
        public static void TypeLoaderApisAfterDispose()
        {
            TypeLoader tl = new TypeLoader();

            tl.Dispose();

            Assert.Throws <ObjectDisposedException>(() => tl.LoadFromAssemblyName(new AssemblyName("Foo")));
            Assert.Throws <ObjectDisposedException>(() => tl.LoadFromAssemblyName("Foo"));
            Assert.Throws <ObjectDisposedException>(() => tl.LoadFromAssemblyPath("Foo"));
            Assert.Throws <ObjectDisposedException>(() => tl.LoadFromByteArray(TestData.s_SimpleAssemblyImage));
            Assert.Throws <ObjectDisposedException>(() => tl.LoadFromStream(new MemoryStream(TestData.s_SimpleAssemblyImage)));
            Assert.Throws <ObjectDisposedException>(() => tl.CoreAssemblyName = "Foo");
            Assert.Throws <ObjectDisposedException>(() => tl.CoreAssemblyName);
            Assert.Throws <ObjectDisposedException>(() => tl.GetAssemblies());
        }