using System; using System.Net.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options; using Novaloop.PaymoApi.Extensions; using Novaloop.PaymoApi.Shared; namespace Novaloop.PaymoApi.Tests { public static class DependencyFactory { public static ApiClient GeneratePaymoApiClient() { return new ApiClient(new HttpClient {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 ApiOptions {ApiToken = paymoToken}); } } }