From 32b488c50fe34beeba5217780ebbe0b430620331 Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 19 Jan 2026 15:56:12 +0100 Subject: [PATCH] Refactor test dependency resolution in DocSignedNotificationTests Refactored DocSignedNotificationTests to use typed repository retrieval and explicit service resolution for PsPdfKitAnnotation. Added a Services property to TestBase for easier access to IServiceProvider. These changes improve clarity and robustness of test dependency management. --- EnvelopeGenerator.Tests/DocSignedNotificationTests.cs | 11 +++++++++-- EnvelopeGenerator.Tests/TestBase.cs | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/EnvelopeGenerator.Tests/DocSignedNotificationTests.cs b/EnvelopeGenerator.Tests/DocSignedNotificationTests.cs index 9ce6dd8a..0f520606 100644 --- a/EnvelopeGenerator.Tests/DocSignedNotificationTests.cs +++ b/EnvelopeGenerator.Tests/DocSignedNotificationTests.cs @@ -5,6 +5,7 @@ using DigitalData.EmailProfilerDispatcher.Abstraction.Entities; using EnvelopeGenerator.Application.Common.Dto.EnvelopeReceiver; using EnvelopeGenerator.Application.Common.Notifications.DocSigned; using EnvelopeGenerator.Application.Common.Notifications.DocSigned.Handlers; +using EnvelopeGenerator.Domain.Entities; using Microsoft.Extensions.DependencyInjection; namespace EnvelopeGenerator.Tests; @@ -44,9 +45,15 @@ public class DocSignedNotificationTests : TestBase // Create envelope receiver var envRcv = this.CreateEnvelopeReceiver(env!.Id, rcv.Id); - envRcv = await Repository.CreateAsync(envRcv, cancel); + + var repo = GetRepository(); + + envRcv = await repo.CreateAsync(envRcv, cancel); var envRcvDto = _mapper.Map(envRcv); - var docSignedNtf = envRcvDto.ToDocSignedNotification(new () { }); + + var annots = Services.GetRequiredService(); + + var docSignedNtf = envRcvDto.ToDocSignedNotification(annots); var sendSignedMailHandler = Host.Services.GetRequiredService(); diff --git a/EnvelopeGenerator.Tests/TestBase.cs b/EnvelopeGenerator.Tests/TestBase.cs index f22caf41..391e85f4 100644 --- a/EnvelopeGenerator.Tests/TestBase.cs +++ b/EnvelopeGenerator.Tests/TestBase.cs @@ -24,6 +24,8 @@ public abstract class TestBase : Faker protected IRepository Repository => Host.Services.GetRequiredService(); + protected IServiceProvider Services => Host.Services; + protected abstract void ConfigureServices(IServiceCollection services); [SetUp]