public static async Task <JobHostHelper <T> > RunFor(ILoggerFactory loggerFactory, bool waitForAllConnectionToBeConnected = true) { var config = new JobHostConfiguration(); config.TypeLocator = new ExplicitTypeLocator(typeof(T)); config.LoggerFactory = loggerFactory; config.UseDevelopmentSettings(); config.UseMqtt(); var jobHost = new JobHost(config); try { await jobHost.StartAsync(); } catch (InvalidOperationException ex) { throw new Exception("In order to be able to run this integration tests, make sure you have the Azure Storage Emulator running or configure a connection to a real Azure Storage Account in the appsettings.json", ex); } var jobHostHelper = new JobHostHelper <T>(jobHost); if (waitForAllConnectionToBeConnected) { await jobHostHelper.WaitForAllConnectionToBeConnected(); } return(jobHostHelper); }
public static async Task <JobHostHelper <T> > RunFor(ILoggerProvider loggerProvider, bool waitForAllConnectionToBeConnected = true) { var locator = new ExplicitTypeLocator(typeof(T)); IHost host = new HostBuilder() .ConfigureWebJobs(builder => { builder.AddMqtt(); }) .ConfigureServices(services => { services.AddSingleton <ITypeLocator>(locator); }) .ConfigureLogging(logging => { logging.ClearProviders(); logging.AddProvider(loggerProvider); }) .Build(); try { await host.StartAsync(); } catch (InvalidOperationException ex) { throw new Exception("In order to be able to run this integration tests, make sure you have the Azure Storage Emulator running or configure a connection to a real Azure Storage Account in the appsettings.json", ex); } var jobHostHelper = new JobHostHelper <T>(host); if (waitForAllConnectionToBeConnected) { await jobHostHelper.WaitForAllConnectionToBeConnected(); } return(jobHostHelper); }