コード例 #1
0
        void VerifyTestResolve()
        {
            TestResolve.Assert(ResolveEvents.ExpectedEvent, () => AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName("TestDefaultLoad")));
            TestResolve.Assert(ResolveEvents.NoEvent, () => AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName("TestIsolatedLoad")));
            TestResolve.Assert(ResolveEvents.ExpectedEvent, () => alc.LoadFromAssemblyName(new AssemblyName("TestIsolatedLoad")));
            TestResolve.Assert(ResolveEvents.ExpectedEvent, () => alc.LoadFromAssemblyName(new AssemblyName("TestDefaultLoad")));

            // Make sure failure is not cached
            TestResolve.Assert(ResolveEvents.ExpectedEvent, () => AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName("TestDefaultLoad")));
            TestResolve.Assert(ResolveEvents.NoEvent, () => AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName("TestIsolatedLoad")));
            TestResolve.Assert(ResolveEvents.ExpectedEvent, () => alc.LoadFromAssemblyName(new AssemblyName("TestIsolatedLoad")));
            TestResolve.Assert(ResolveEvents.ExpectedEvent, () => alc.LoadFromAssemblyName(new AssemblyName("TestDefaultLoad")));
        }
コード例 #2
0
 void TestResolveMissingAssembly(bool isolated, Action <string> action, bool skipNullIsolated = false)
 {
     using (ConntextualReflectionProxy.EnterContextualReflection((Assembly)null))
     {
         TestResolve.Assert(ResolveEvents.ExpectedEvent, () => action("TestDefaultLoad"));
         if (!skipNullIsolated)
         {
             TestResolve.Assert(isolated ? ResolveEvents.ExpectedEvent : ResolveEvents.NoEvent, () => action("TestIsolatedLoad"));
         }
     }
     using (ConntextualReflectionProxy.EnterContextualReflection(AssemblyLoadContext.Default))
     {
         TestResolve.Assert(ResolveEvents.ExpectedEvent, () => action("TestDefaultLoad"));
         TestResolve.Assert(ResolveEvents.NoEvent, () => action("TestIsolatedLoad"));
     }
     using (ConntextualReflectionProxy.EnterContextualReflection(alc))
     {
         TestResolve.Assert(ResolveEvents.ExpectedEvent, () => action("TestDefaultLoad"));
         TestResolve.Assert(ResolveEvents.ExpectedEvent, () => action("TestIsolatedLoad"));
     }
 }