diff --git a/EnvelopeGenerator.Tests.Application/Fake.cs b/EnvelopeGenerator.Tests.Application/Fake.cs index e1aa9627..c7a9d080 100644 --- a/EnvelopeGenerator.Tests.Application/Fake.cs +++ b/EnvelopeGenerator.Tests.Application/Fake.cs @@ -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(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(this Faker fake, string key, Constants.EnvelopeStatus? status = null) + where TEnvelopeQuery : EnvelopeQueryBase + where TReceiverQuery : ReceiverQueryBase + { + return new() + { + Status = status ?? fake.PickEnum(), + Comment = fake.Lorem.Sentence(), + Key = key, + }; + } + #endregion + #region User Command public static CreateUserCommand CreateUserCommand(this Faker fake) => new() {