Refactor test namespaces to EnvelopeGenerator.Tests.Application
All test files and utilities now use the EnvelopeGenerator.Tests.Application namespace for improved organization and clarity. No functional changes were made; updates are limited to namespaces and using directives. This makes it explicit that these are application-level tests and related helpers.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using AutoMapper;
|
||||
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.Notifications.DocSigned;
|
||||
using EnvelopeGenerator.Application.Common.Notifications.DocSigned.Handlers;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace EnvelopeGenerator.Tests.Application;
|
||||
|
||||
public class DocSignedNotificationTests : TestBase
|
||||
{
|
||||
protected IMapper _mapper;
|
||||
|
||||
protected override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<SendSignedMailHandler>();
|
||||
|
||||
// overwrite EmailOutRepository
|
||||
services.AddDbRepository(opt => opt.RegisterEntity<Fake.EGDbContext2Prod, EmailOut>(ctx => ctx.EMailOuts));
|
||||
}
|
||||
|
||||
public override async Task Setup()
|
||||
{
|
||||
await base.Setup();
|
||||
_mapper = Host.Services.GetRequiredService<IMapper>();
|
||||
}
|
||||
|
||||
[TestCase("h.tek@digitaldata.works", TestName = "SendSignedMailHandler_ShouldNotThrow_WithValidEmail")]
|
||||
public async Task SendSignedMailHandler_ShouldNotThrow(string emailAddress)
|
||||
{
|
||||
/// Assert
|
||||
CancellationToken cancel = new();
|
||||
var mediator = Mediator;
|
||||
|
||||
// Create envelope
|
||||
var envCmd = this.CreateEnvelopeCommand(User.Id);
|
||||
var env = await mediator.Send(envCmd, cancel);
|
||||
|
||||
// Create receiver
|
||||
var rcvCmd = this.CreateReceiverCommand(emailAddress);
|
||||
(var rcv, _) = await mediator.Send(rcvCmd, cancel);
|
||||
|
||||
// Create envelope receiver
|
||||
var envRcv = this.CreateEnvelopeReceiver(env!.Id, rcv.Id);
|
||||
|
||||
var repo = GetRepository<EnvelopeReceiver>();
|
||||
|
||||
envRcv = await repo.CreateAsync(envRcv, cancel);
|
||||
var envRcvDto = _mapper.Map<EnvelopeReceiverDto>(envRcv);
|
||||
|
||||
var annots = Services.GetRequiredService<PsPdfKitAnnotation>();
|
||||
|
||||
var docSignedNtf = envRcvDto.ToDocSignedNotification(annots);
|
||||
|
||||
var sendSignedMailHandler = Host.Services.GetRequiredService<SendSignedMailHandler>();
|
||||
|
||||
// Act + Assert
|
||||
Assert.DoesNotThrowAsync(async () => await sendSignedMailHandler.Handle(docSignedNtf, cancel));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user