mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-04-05 18:09:04 +00:00
* remove email out of register service * Update auth service, move JWT handling out of controller * add docker config for service auth test * Update mock email system * Format: ./src/Core/Service * Refactor authentication payloads and services for registration and login processes * Format: src/Core/API, src/Core/Service
47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using API.Specs.Mocks;
|
|
using Infrastructure.Email;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Mvc.Testing;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Service.Emails;
|
|
|
|
namespace API.Specs
|
|
{
|
|
public class TestApiFactory : WebApplicationFactory<Program>
|
|
{
|
|
protected override void ConfigureWebHost(IWebHostBuilder builder)
|
|
{
|
|
builder.UseEnvironment("Testing");
|
|
|
|
builder.ConfigureServices(services =>
|
|
{
|
|
// Replace the real email provider with mock for testing
|
|
var emailProviderDescriptor = services.SingleOrDefault(d =>
|
|
d.ServiceType == typeof(IEmailProvider)
|
|
);
|
|
|
|
if (emailProviderDescriptor != null)
|
|
{
|
|
services.Remove(emailProviderDescriptor);
|
|
}
|
|
|
|
services.AddScoped<IEmailProvider, MockEmailProvider>();
|
|
|
|
// Replace the real email service with mock for testing
|
|
var emailServiceDescriptor = services.SingleOrDefault(d =>
|
|
d.ServiceType == typeof(IEmailService)
|
|
);
|
|
|
|
if (emailServiceDescriptor != null)
|
|
{
|
|
services.Remove(emailServiceDescriptor);
|
|
}
|
|
|
|
services.AddScoped<IEmailService, MockEmailService>();
|
|
});
|
|
}
|
|
}
|
|
}
|