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:
119
EnvelopeGenerator.Tests/Application/HistoryTests.cs
Normal file
119
EnvelopeGenerator.Tests/Application/HistoryTests.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using EnvelopeGenerator.Application.Common.Dto.History;
|
||||
using EnvelopeGenerator.Application.Common.Extensions;
|
||||
using EnvelopeGenerator.Application.Histories.Commands;
|
||||
using EnvelopeGenerator.Application.Histories.Queries;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace EnvelopeGenerator.Tests.Application;
|
||||
|
||||
[TestFixture]
|
||||
public class HistoryTests : TestBase
|
||||
{
|
||||
protected override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public override Task Setup()
|
||||
{
|
||||
return base.Setup();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public override void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateHistory_And_ReadHistory_Should_Work()
|
||||
{
|
||||
/// Arrange
|
||||
CancellationToken cancel = default;
|
||||
|
||||
// Create envelope
|
||||
var envelope = FakeEnvelope;
|
||||
envelope = await GetRepository<Envelope>().CreateAsync(envelope, cancel);
|
||||
|
||||
// Create receiver
|
||||
var createReceiverCmd = this.CreateReceiverCommand();
|
||||
(var receiver, _) = await Mediator.Send(createReceiverCmd);
|
||||
|
||||
// Create envelope receiver
|
||||
var envRcv = this.CreateEnvelopeReceiver(envelope.Id, receiver.Id);
|
||||
envRcv = await GetRepository<EnvelopeReceiver>().CreateAsync(envRcv, cancel);
|
||||
|
||||
var key = (envelope.Uuid, receiver.Signature).ToEnvelopeKey();
|
||||
|
||||
var createCmd = Fake.Provider.CreateHistoryCommand(key);
|
||||
|
||||
// Act
|
||||
var hist = await Mediator.Send(createCmd);
|
||||
|
||||
// Assert
|
||||
Assert.That(hist, Is.Not.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ReadHistory_Should_Filter_By_Status()
|
||||
{
|
||||
/// Arrange
|
||||
CancellationToken cancel = default;
|
||||
|
||||
// Create envelope
|
||||
var envelope = FakeEnvelope;
|
||||
envelope = await GetRepository<Envelope>().CreateAsync(envelope, cancel);
|
||||
|
||||
// Create receiver
|
||||
var createReceiverCmd = this.CreateReceiverCommand();
|
||||
(var receiver, _) = await Mediator.Send(createReceiverCmd);
|
||||
|
||||
// Create envelope receiver
|
||||
var envRcv = this.CreateEnvelopeReceiver(envelope.Id, receiver.Id);
|
||||
envRcv = await GetRepository<EnvelopeReceiver>().CreateAsync(envRcv, cancel);
|
||||
|
||||
var createCmd1 = new CreateHistoryCommand
|
||||
{
|
||||
EnvelopeId = envelope.Id,
|
||||
UserReference = receiver.EmailAddress,
|
||||
Status = EnvelopeStatus.AccessCodeRequested
|
||||
};
|
||||
|
||||
var createCmd2 = new CreateHistoryCommand
|
||||
{
|
||||
EnvelopeId = envelope.Id,
|
||||
UserReference = receiver.EmailAddress,
|
||||
Status = EnvelopeStatus.EnvelopeCompletelySigned
|
||||
};
|
||||
|
||||
await Mediator.Send(createCmd1, cancel);
|
||||
await Mediator.Send(createCmd2, cancel);
|
||||
|
||||
// Act
|
||||
var readQuery = new ReadHistoryQuery()
|
||||
{
|
||||
EnvelopeId = envelope.Id,
|
||||
Status = EnvelopeStatus.EnvelopeCompletelySigned
|
||||
};
|
||||
var result = await Mediator.Send(readQuery, cancel);
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Has.Exactly(1).Items);
|
||||
Assert.That(result, Has.All.Matches<HistoryDto>(r => r.Status == EnvelopeStatus.EnvelopeCompletelySigned));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ReadHistory_Should_Return_Empty_When_No_Record()
|
||||
{
|
||||
// Act
|
||||
var result = await Mediator.Send(new ReadHistoryQuery()
|
||||
{
|
||||
EnvelopeId = 9999
|
||||
});
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.Empty);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user