示例#1
0
        public static FunctionMetadataManager GetFunctionMetadataManager(IOptions <ScriptJobHostOptions> jobHostOptions, Mock <IScriptHostManager> managerMock,
                                                                         IFunctionMetadataProvider functionMetadataProvider, IList <IFunctionProvider> functionProviders, IOptions <HttpWorkerOptions> httpOptions, ILoggerFactory loggerFactory, IOptions <LanguageWorkerOptions> languageWorkerOptions)
        {
            managerMock.As <IServiceProvider>().Setup(m => m.GetService(typeof(IEnumerable <IFunctionProvider>))).Returns(functionProviders);
            managerMock.As <IServiceProvider>().Setup(m => m.GetService(typeof(IOptions <ScriptJobHostOptions>))).Returns(jobHostOptions);
            managerMock.As <IServiceProvider>().Setup(m => m.GetService(typeof(IOptions <HttpWorkerOptions>))).Returns(httpOptions);
            managerMock.As <IServiceProvider>().Setup(m => m.GetService(typeof(IOptions <LanguageWorkerOptions>))).Returns(languageWorkerOptions);
            managerMock.As <IServiceProvider>().Setup(m => m.GetService(typeof(ILoggerFactory))).Returns(loggerFactory);

            var options = new ScriptApplicationHostOptions()
            {
                IsSelfHost = true,
                ScriptPath = TestHelpers.FunctionsTestDirectory,
                LogPath    = TestHelpers.GetHostLogFileDirectory().FullName
            };
            var factory        = new TestOptionsFactory <ScriptApplicationHostOptions>(options);
            var source         = new TestChangeTokenSource <ScriptApplicationHostOptions>();
            var changeTokens   = new[] { source };
            var optionsMonitor = new OptionsMonitor <ScriptApplicationHostOptions>(factory, changeTokens, factory);

            return(new FunctionMetadataManager(jobHostOptions, functionMetadataProvider, httpOptions, managerMock.Object, loggerFactory, languageWorkerOptions, SystemEnvironment.Instance));
        }