using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using SmsSluzba.Api.Config; using SmsSluzba.Api.Gateway; namespace SmsSluzba.Api.Tests.Api; internal sealed class SmsApiFactory(FakeGatewayHandler gateway) : WebApplicationFactory { public const string ApiKey = "test-key-eshop"; public const string GatewayPassword = "gateway-password"; protected override void ConfigureWebHost(IWebHostBuilder builder) { builder.UseSetting(AppSettingsLoader.LoginKey, "gateway-login"); builder.UseSetting(AppSettingsLoader.PasswordKey, GatewayPassword); builder.UseSetting(AppSettingsLoader.ApiKeysKey, "eshop=" + ApiKey); builder.ConfigureTestServices(services => services.AddHttpClient().ConfigurePrimaryHttpMessageHandler(() => gateway)); } }