Updated references from `Constants` to direct usage of `EnvelopeStatus` and `EmailTemplateType` enums. This change enhances code readability and reduces dependency on the `Constants` class. Modified properties and parameters across command classes, DTOs, repositories, and services to use the enums directly. Updated `ModifyDocStatusCommandBase`, `EnvelopeHistoryDto`, and `ResetEmailTemplateCommand` for improved clarity. Consistent updates across multiple files indicate a systematic refactoring aimed at streamlining the codebase and improving maintainability. Comments and documentation have also been revised to reflect these changes.
89 lines
2.3 KiB
C#
89 lines
2.3 KiB
C#
using EnvelopeGenerator.Application.Histories.Commands;
|
|
using EnvelopeGenerator.Application.Histories.Queries;
|
|
using EnvelopeGenerator.Domain;
|
|
|
|
namespace EnvelopeGenerator.Tests.Application;
|
|
|
|
[TestFixture]
|
|
public class HistoryTests
|
|
{
|
|
private Fake.Host _host;
|
|
|
|
[SetUp]
|
|
public async Task Setup()
|
|
{
|
|
_host = Fake.CreateHost();
|
|
await _host.AddSampleReceivers();
|
|
}
|
|
|
|
[TearDown]
|
|
public void TearDown()
|
|
{
|
|
_host.Dispose();
|
|
}
|
|
|
|
[Test]
|
|
public async Task CreateHistory_And_ReadHistory_Should_Work()
|
|
{
|
|
// Arrange
|
|
var createCmd = new CreateHistoryCommand
|
|
{
|
|
EnvelopeId = 1,
|
|
UserReference = "UserA",
|
|
Status = EnvelopeStatus.EnvelopeCreated,
|
|
Comment = "First create"
|
|
};
|
|
|
|
// Act
|
|
var id = await _host.Mediator.Send(createCmd);
|
|
|
|
// Assert
|
|
Assert.That(id, Is.Not.Null);
|
|
|
|
// ReadHistory query
|
|
var query = new ReadHistoryQuery(1);
|
|
var result = await _host.Mediator.Send(query);
|
|
|
|
Assert.That(result, Is.Not.Empty);
|
|
}
|
|
|
|
[Test]
|
|
public async Task ReadHistory_Should_Filter_By_Status()
|
|
{
|
|
// Arrange
|
|
var createCmd1 = new CreateHistoryCommand
|
|
{
|
|
EnvelopeId = 2,
|
|
UserReference = "UserX",
|
|
Status = EnvelopeStatus.EnvelopeCreated
|
|
};
|
|
|
|
var createCmd2 = new CreateHistoryCommand
|
|
{
|
|
EnvelopeId = 2,
|
|
UserReference = "UserX",
|
|
Status = EnvelopeStatus.EnvelopePartlySigned
|
|
};
|
|
|
|
await _host.Mediator.Send(createCmd1);
|
|
await _host.Mediator.Send(createCmd2);
|
|
|
|
// Act
|
|
var result = await _host.Mediator.Send(new ReadHistoryQuery(2, EnvelopeStatus.EnvelopePartlySigned));
|
|
|
|
// Assert
|
|
Assert.That(result, Has.Exactly(1).Items);
|
|
Assert.That(result, Has.All.Matches<EnvelopeGenerator.Application.Dto.EnvelopeHistory.EnvelopeHistoryDto>(
|
|
r => r.Status == EnvelopeStatus.EnvelopePartlySigned));
|
|
}
|
|
|
|
[Test]
|
|
public async Task ReadHistory_Should_Return_Empty_When_No_Record()
|
|
{
|
|
// Act
|
|
var result = await _host.Mediator.Send(new ReadHistoryQuery(999));
|
|
|
|
// Assert
|
|
Assert.That(result, Is.Empty);
|
|
}
|
|
} |