refactor(DocSignedNotificationTests): add again EmailOut DbRepository using Fake.EGDbContext2Prod

- create base EGDbContextBase to be able to add custom DbContextOptions
This commit is contained in:
2025-09-15 14:02:58 +02:00
parent 9eaa777fb6
commit b5fec7bb46
3 changed files with 17 additions and 5 deletions

View File

@@ -14,8 +14,15 @@ using EnvelopeGenerator.Application.Common.Configurations;
namespace EnvelopeGenerator.Infrastructure; namespace EnvelopeGenerator.Infrastructure;
public class EGDbContext : EGDbContextBase
{
public EGDbContext(DbContextOptions<EGDbContext> options, IOptions<DbTriggerParams> triggerParamOptions, ILogger<EGDbContext>? logger = null) : base(options, triggerParamOptions, logger)
{
}
}
//TODO: Adding EmailOut instead of EmailOut.Abst is not correct for the arch. Re-design EmailPut consedering this. IMailDbContext shoud move to Abstraction layer (hint: in this case using DBSet in abst. will be problem because entity framework will have to be added. //TODO: Adding EmailOut instead of EmailOut.Abst is not correct for the arch. Re-design EmailPut consedering this. IMailDbContext shoud move to Abstraction layer (hint: in this case using DBSet in abst. will be problem because entity framework will have to be added.
public class EGDbContext : DbContext, IUserManagerDbContext, IMailDbContext public abstract class EGDbContextBase : DbContext, IUserManagerDbContext, IMailDbContext
{ {
public DbSet<Config> Configs { get; set; } public DbSet<Config> Configs { get; set; }
@@ -57,11 +64,11 @@ public class EGDbContext : DbContext, IUserManagerDbContext, IMailDbContext
private readonly DbTriggerParams _triggers; private readonly DbTriggerParams _triggers;
private readonly ILogger<EGDbContext>? _logger; private readonly ILogger? _logger;
public bool IsMigration { get; set; } = false; public bool IsMigration { get; set; } = false;
public EGDbContext(DbContextOptions<EGDbContext> options, IOptions<DbTriggerParams> triggerParamOptions, ILogger<EGDbContext>? logger = null) : base(options) public EGDbContextBase(DbContextOptions options, IOptions<DbTriggerParams> triggerParamOptions, ILogger? logger = null) : base(options)
{ {
_triggers = triggerParamOptions.Value; _triggers = triggerParamOptions.Value;
_logger = logger; _logger = logger;

View File

@@ -1,5 +1,7 @@
using AutoMapper; using AutoMapper;
using DigitalData.Core.Abstraction.Application.Repository; using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Infrastructure;
using DigitalData.EmailProfilerDispatcher.Abstraction.Entities;
using EnvelopeGenerator.Application.Common.Dto.EnvelopeReceiver; using EnvelopeGenerator.Application.Common.Dto.EnvelopeReceiver;
using EnvelopeGenerator.Application.Common.Notifications.DocSigned; using EnvelopeGenerator.Application.Common.Notifications.DocSigned;
using EnvelopeGenerator.Application.Common.Notifications.DocSigned.Handlers; using EnvelopeGenerator.Application.Common.Notifications.DocSigned.Handlers;
@@ -14,6 +16,9 @@ public class DocSignedNotificationTests : TestBase
protected override void ConfigureServices(IServiceCollection services) protected override void ConfigureServices(IServiceCollection services)
{ {
services.AddTransient<SendSignedMailHandler>(); services.AddTransient<SendSignedMailHandler>();
// overwrite EmailOutRepository
services.AddDbRepository(opt => opt.RegisterEntity<Fake.EGDbContext2Prod, EmailOut>(ctx => ctx.EMailOuts))
} }
public override async Task Setup() public override async Task Setup()

View File

@@ -139,9 +139,9 @@ public class Fake
/// Represents a mock database context that inherits from <see cref="EGDbContext"/>. /// Represents a mock database context that inherits from <see cref="EGDbContext"/>.
/// This context is intended for testing purposes while connecting to the production database. /// This context is intended for testing purposes while connecting to the production database.
/// </summary> /// </summary>
public class EGDbContext2Prod : EGDbContext public class EGDbContext2Prod : EGDbContextBase
{ {
public EGDbContext2Prod(DbContextOptions<EGDbContext> options, IOptions<DbTriggerParams> triggerParamOptions, ILogger<EGDbContext>? logger = null) : base(options, triggerParamOptions, logger) public EGDbContext2Prod(DbContextOptions<EGDbContext2Prod> options, IOptions<DbTriggerParams> triggerParamOptions, ILogger<EGDbContext>? logger = null) : base(options, triggerParamOptions, logger)
{ {
} }
} }