Beispiel #1
0
        public static void Unload_CollectibleWithNoAssemblyLoaded()
        {
            // Use a collectible ALC + Unload
            // Check that we receive the Unloading event

            var checker = new CollectibleChecker(1);

            CreateAndLoadContext(checker);
            checker.GcAndCheck();
        }
Beispiel #2
0
        public static void Finalizer_CollectibleWithNoAssemblyLoaded()
        {
            // Use a collectible ALC, let the finalizer call Unload
            // Check that we receive the Unloading event

            var checker = new CollectibleChecker(1);
            // Create the ALC in another method to allow the finalizer to run
            WeakReference <AssemblyLoadContext> weakRef = CreateCollectible(checker);

            checker.GcAndCheck();

            // Check that the ALC was also released
            AssemblyLoadContext alc;

            Assert.False(weakRef.TryGetTarget(out alc));
        }
Beispiel #3
0
 public void CheckContextUnloaded()
 {
     // The type should now be unloaded
     _checker.GcAndCheck();
 }