using System; using System.Net.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; using Novaloop.PaymoApi.Extensions; using Novaloop.PaymoApi.Shared; namespace Novaloop.PaymoApi.Tests { public static class DependencyFactory { public static PaymoPaymoIApiClient GeneratePaymoApiClient() { return new PaymoPaymoIApiClient(new HttpClient(new PaymoLoggingHandler(new HttpClientHandler(), new NullLogger())) {BaseAddress = new Uri("https://app.paymoapp.com/")}); } public static IOptions GenerateOptions() { var paymoToken = new ConfigurationBuilder() .SetBasePath(AppContext.BaseDirectory) .AddJsonFile("appsettings.tests.json", true, true) .AddEnvironmentVariables() .Build() .GetSection("PaymoApiIntegrationTests:PaymoTestProjectToken").Value; if (string.IsNullOrWhiteSpace(paymoToken)) { throw new ArgumentException("Please set the environment variable 'PAYMOAPIINTEGRATIONTESTS__PAYMOTESTPROJECTTOKEN' with the token of your paymo test-project. Look inside Bitwarden if you work @ Novaloop."); } return Options.Create(new PaymoApiOptions {ApiToken = paymoToken}); } } }