57 lines
2.1 KiB
C#
57 lines
2.1 KiB
C#
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 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);
|
|
envRcv = await Repository.CreateAsync(envRcv, cancel);
|
|
var envRcvDto = _mapper.Map<EnvelopeReceiverDto>(envRcv);
|
|
var docSignedNtf = envRcvDto.ToDocSignedNotification(new () { });
|
|
|
|
var sendSignedMailHandler = Host.Services.GetRequiredService<SendSignedMailHandler>();
|
|
|
|
// Act + Assert
|
|
Assert.DoesNotThrowAsync(async () => await sendSignedMailHandler.Handle(docSignedNtf, cancel));
|
|
}
|
|
}
|