private static void ConfigureWireMockService(IServiceCollection services) { services.AddSingleton <IWireMockHttpService>(provider => { var opts = provider.GetService <IOptions <ApiStubOptions> >().Value; var repo = provider.GetService <IDataRepository>(); var httpClient = new WireMockHttpClient { BaseAddress = new Uri(opts.WireMockServiceApiBaseUrl) }; return(new WireMockHttpService(httpClient, repo)); }); }
public WireMockHttpService(WireMockHttpClient client, IDataRepository repository) { _client = client; _repository = repository; try { _mockServer = WireMockServer.Start(Guid.NewGuid().ToString()); } catch (Exception e) { Console.WriteLine("FAILED TO START WIREMOCK SERVICE"); Console.WriteLine(e); throw; } }