示例#1
0
        /// <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));
        }
示例#2
0
        /// <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));
        }