Refactor test namespaces; update package version
Changed test file namespaces from EnvelopeGenerator.Tests.Application to EnvelopeGenerator.Tests for consistency. Updated DigitalData.Core.Abstraction.Application package from 1.4.0 to 1.6.0 to incorporate latest improvements.
This commit is contained in:
56
EnvelopeGenerator.Tests/DocSignedNotificationTests.cs
Normal file
56
EnvelopeGenerator.Tests/DocSignedNotificationTests.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
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;
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user