Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Orbit.Application.Common;
using Orbit.Domain.Interfaces;

namespace Orbit.IntegrationTests;

Expand Down Expand Up @@ -36,13 +38,17 @@ static IntegrationTestWebApplicationFactory()
/// </summary>
public CapturingBillingService BillingService { get; } = new();

public CapturingEmailService Email { get; } = new();

protected override void ConfigureWebHost(IWebHostBuilder builder)
{
builder.UseSetting("Jwt:SecretKey", "OrbitIntegrationTestSecretKey-0123456789-ABCDEF");

builder.ConfigureTestServices(services =>
{
services.AddScoped<IBillingService>(_ => BillingService);
services.RemoveAll<IEmailService>();
services.AddSingleton<IEmailService>(Email);
});
}

Expand Down Expand Up @@ -72,3 +78,23 @@ private static string BuildClientIpAddress()
return $"198.51.{thirdOctet}.{fourthOctet}";
}
}

public sealed class CapturingEmailService : IEmailService
{
public string? LastVerificationCode { get; private set; }

public Task SendWelcomeEmailAsync(string toEmail, string userName, string language = "en", CancellationToken cancellationToken = default)
=> Task.CompletedTask;

public Task SendVerificationCodeAsync(string toEmail, string code, string language = "en", CancellationToken cancellationToken = default)
{
LastVerificationCode = code;
return Task.CompletedTask;
}

public Task SendSupportEmailAsync(string fromName, string fromEmail, string subject, string message, CancellationToken cancellationToken = default)
=> Task.CompletedTask;

public Task SendAccountDeletionCodeAsync(string toEmail, string code, string language = "en", CancellationToken cancellationToken = default)
=> Task.CompletedTask;
}
Loading
Loading