public void DefaultContextAssembly_LoadedIntoSharedContext_UsesRuntimeAssembly()
        {
            using (var tempFolder = new TempDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())))
                using (var env = new TestScopedEnvironmentVariable(EnvironmentSettingNames.AzureWebJobsScriptRoot, tempFolder.Path))
                {
                    // Arrange
                    var      sharedContext          = new FunctionAssemblyLoadContext(tempFolder.Path);
                    Assembly targetAssembly         = typeof(DynamicFunctionAssemblyLoadContextTests).Assembly;
                    string   originalLocation       = targetAssembly.Location;
                    string   targetAssemblyLocation = Path.Combine(tempFolder.Path, Path.GetFileName(originalLocation));

                    File.Copy(originalLocation, targetAssemblyLocation);

                    var metadata1Directory = @"c:\testroot\test1";
                    var metadata1          = new WebJobs.Script.Description.FunctionMetadata {
                        Name = "Test1", ScriptFile = $@"{metadata1Directory}\test.tst"
                    };

                    var mockResolver = new Mock <IFunctionMetadataResolver>();

                    var loadContext = new TestDynamicAssemblyLoadContext(metadata1, mockResolver.Object, NullLogger.Instance, sharedContext);

                    // Act
                    Assembly result = loadContext.LoadFromAssemblyName(targetAssembly.GetName());

                    // Assert
                    Assert.NotNull(result);
                    Assert.Same(AssemblyLoadContext.Default, AssemblyLoadContext.GetLoadContext(result));
                }
        }
 public TestDynamicAssemblyLoadContext(WebJobs.Script.Description.FunctionMetadata functionMetadata,
                                       IFunctionMetadataResolver resolver, ILogger logger, FunctionAssemblyLoadContext sharedContext)
     : base(functionMetadata, resolver, logger)
 {
     _sharedContext = sharedContext;
 }