using System.Net.Http.Headers; using System.Text.Json; using AsbCloudDb.Model; using AsbCloudWebApi.IntegrationTests.Clients; using Microsoft.Extensions.DependencyInjection; using Refit; using Xunit; namespace AsbCloudWebApi.IntegrationTests; public abstract class BaseIntegrationTest : IClassFixture { private readonly IServiceScope scope; private readonly HttpClient httpClient; protected readonly IAsbCloudDbContext dbContext; protected IAdminDepositClient adminDepositClient; protected BaseIntegrationTest(WebAppFactoryFixture factory) { scope = factory.Services.CreateScope(); httpClient = factory.CreateClient(); dbContext = scope.ServiceProvider.GetRequiredService(); var jwtToken = ApiTokenHelper.GetAdminUserToken(); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", jwtToken); var jsonSerializerOptions = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, PropertyNameCaseInsensitive = true }; var refitSettings = new RefitSettings(new SystemTextJsonContentSerializer(jsonSerializerOptions)); adminDepositClient = RestService.For(httpClient, refitSettings); } }