Add history command support and enum selection method
- Introduced new using directives for histories and models. - Added `PickEnum<T>` method to randomly select enum values. - Renamed region from `#region Envelope Command` to `#region Envelope`. - Implemented `CreateHistoryCommand<TEnvelopeQuery, TReceiverQuery>` for creating history commands. - Organized new method under a new region `#region History`.
This commit is contained in:
parent
838d7e3ab8
commit
09eb91b6be
@ -4,6 +4,8 @@ using DigitalData.UserManager.Domain.Entities;
|
||||
using EnvelopeGenerator.Application;
|
||||
using EnvelopeGenerator.Application.EnvelopeReceivers.Commands;
|
||||
using EnvelopeGenerator.Application.Envelopes.Commands;
|
||||
using EnvelopeGenerator.Application.Histories.Commands;
|
||||
using EnvelopeGenerator.Application.Model;
|
||||
using EnvelopeGenerator.Application.Receivers.Commands;
|
||||
using EnvelopeGenerator.Application.Users.Commands;
|
||||
using EnvelopeGenerator.Infrastructure;
|
||||
@ -14,6 +16,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Infrastructure;
|
||||
using EnvelopeGenerator.Domain;
|
||||
|
||||
namespace EnvelopeGenerator.Tests.Application;
|
||||
|
||||
@ -128,6 +131,13 @@ public static class Extensions
|
||||
{
|
||||
public static Fake.Host ToFake(this IHost host) => new(host);
|
||||
|
||||
public static T PickEnum<T>(this Faker faker) where T : struct, Enum
|
||||
{
|
||||
var values = Enum.GetValues(typeof(T));
|
||||
var index = faker.Random.Int(0, values.Length - 1);
|
||||
return (T)values.GetValue(index)!;
|
||||
}
|
||||
|
||||
#region Receiver Command
|
||||
public static CreateReceiverCommand CreateReceiverCommand(this Faker fake) => new()
|
||||
{
|
||||
@ -140,7 +150,7 @@ public static class Extensions
|
||||
.ToList();
|
||||
#endregion
|
||||
|
||||
#region Envelope Command
|
||||
#region Envelope
|
||||
public static CreateEnvelopeCommand CreateEnvelopeCommand(this Faker fake, int userId) => new()
|
||||
{
|
||||
Message = fake.Lorem.Paragraph(fake.Random.Number(2, 5)),
|
||||
@ -154,7 +164,7 @@ public static class Extensions
|
||||
.ToList();
|
||||
#endregion
|
||||
|
||||
#region Envelope Document
|
||||
#region Document
|
||||
public static string CreatePdfAsBase64(this Faker faker)
|
||||
{
|
||||
string name = faker.Name.FullName();
|
||||
@ -193,6 +203,20 @@ public static class Extensions
|
||||
.ToList();
|
||||
#endregion
|
||||
|
||||
#region History
|
||||
public static CreateHistoryCommand CreateHistoryCommand<TEnvelopeQuery, TReceiverQuery>(this Faker fake, string key, Constants.EnvelopeStatus? status = null)
|
||||
where TEnvelopeQuery : EnvelopeQueryBase
|
||||
where TReceiverQuery : ReceiverQueryBase
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Status = status ?? fake.PickEnum<Constants.EnvelopeStatus>(),
|
||||
Comment = fake.Lorem.Sentence(),
|
||||
Key = key,
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region User Command
|
||||
public static CreateUserCommand CreateUserCommand(this Faker fake) => new()
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user