/// <summary> /// Setup a webhost to communicate with an in memory acquiring bank /// </summary> private static IServiceCollection AddInMemoryFakeAcquiringBankApi(this IServiceCollection services, ITestOutputHelper testOutputHelper) { var fakeAcquiringBankHostBuilder = FakeAcquiringBankHostBuilder .Create() .ConfigureLogging((paymentGatewayContext, loggingBuilder) => { loggingBuilder.AddProvider(new TestOutputHelperLoggerProvider(testOutputHelper)); }); var fakeAcquiringBankApiTestServer = new TestServer(fakeAcquiringBankHostBuilder); var fakeAcquiringBankHttpClientFactory = new TestServerHttpClientFactory(fakeAcquiringBankApiTestServer); return(services.AddSingleton <IHttpClientFactory>(fakeAcquiringBankHttpClientFactory)); }
/// <summary> /// Setup a host to communicate with an in memory payment gateway. Optionally configures the in memory payment gateway to talk to an in memory fake acquiring bank /// </summary> private static IServiceCollection AddInMemoryPaymentGatewayApi(this IServiceCollection services, ITestOutputHelper testOutputHelper, bool inMemoryFakeAcquiringBankApi) { var paymentGatewayHostBuilder = PaymentGatewayHostBuilder .Create() .ConfigureLogging((paymentGatewayContext, loggingBuilder) => { loggingBuilder .AddConsole() .AddProvider(new TestOutputHelperLoggerProvider(testOutputHelper)); }) .ConfigureServices((context, paymentGatewayServices) => { if (inMemoryFakeAcquiringBankApi) { paymentGatewayServices.AddInMemoryFakeAcquiringBankApi(testOutputHelper); } }); var paymentGatewayApiTestServer = new TestServer(paymentGatewayHostBuilder); var paymentGatewayHttpClientFactory = new TestServerHttpClientFactory(paymentGatewayApiTestServer); return(services.AddSingleton <IHttpClientFactory>(paymentGatewayHttpClientFactory)); }