diff --git a/EnvelopeGenerator.Tests.Application/Fake.cs b/EnvelopeGenerator.Tests.Application/Fake.cs index 45105370..c0245c28 100644 --- a/EnvelopeGenerator.Tests.Application/Fake.cs +++ b/EnvelopeGenerator.Tests.Application/Fake.cs @@ -5,7 +5,6 @@ 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; @@ -16,8 +15,8 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using QuestPDF.Fluent; using QuestPDF.Infrastructure; -using EnvelopeGenerator.Domain; using EnvelopeGenerator.Domain.Constants; +using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Tests.Application; @@ -164,10 +163,29 @@ public static class Extensions => Enumerable.Range(0, userIDs.Length) .Select(fake.CreateEnvelopeCommand) .ToList(); + + public static Envelope CreateEnvelope(this Faker faker, int userId, bool tfaEnabled = false) => new() + { + Id = faker.Random.Number(1, 1000), + UserId = userId, + Status = EnvelopeStatus.EnvelopeCreated, + Uuid = Guid.NewGuid().ToString(), + Title = faker.Lorem.Paragraph(faker.Random.Number(1, 2)), + Message = faker.Lorem.Paragraph(faker.Random.Number(2, 5)), + TfaEnabled = tfaEnabled, + AddedWhen = DateTime.UtcNow, + CertificationType = (int)CertificationType.AdvancedElectronicSignature, + UseAccessCode = false, + ContractType = (int)ContractType.Contract, + Language = "de", + SendReminderEmails = false, + Comment = faker.Lorem.Sentence(10), + DocResult = faker.CreatePdfAsByte() + }; #endregion #region Document - public static string CreatePdfAsBase64(this Faker faker) + public static byte[] CreatePdfAsByte(this Faker faker) { string name = faker.Name.FullName(); string address = faker.Address.FullAddress(); @@ -191,9 +209,11 @@ public static class Extensions using var ms = new MemoryStream(); document.GeneratePdf(ms); - return Convert.ToBase64String(ms.ToArray()); + return ms.ToArray(); } + public static string CreatePdfAsBase64(this Faker faker) => Convert.ToBase64String(faker.CreatePdfAsByte()); + public static DocumentCreateCommand CreateDocumentCommand(this Faker faker) => new() { DataAsBase64 = faker.CreatePdfAsBase64() diff --git a/EnvelopeGenerator.Tests.Application/TestBase.cs b/EnvelopeGenerator.Tests.Application/TestBase.cs index 098a8b54..1a2ace1f 100644 --- a/EnvelopeGenerator.Tests.Application/TestBase.cs +++ b/EnvelopeGenerator.Tests.Application/TestBase.cs @@ -1,7 +1,7 @@ using Bogus; using DigitalData.UserManager.Domain.Entities; using EnvelopeGenerator.Application.Envelopes.Commands; -using EnvelopeGenerator.Application.Receivers.Commands; +using EnvelopeGenerator.Domain.Entities; using MediatR; namespace EnvelopeGenerator.Tests.Application; @@ -16,6 +16,8 @@ public class TestBase : Faker public CreateEnvelopeCommand FakeCreateEnvelopeCommand => this.CreateEnvelopeCommand(Host.User.Id); + public Envelope FakeEnvelope => this.CreateEnvelope(Host.User.Id); + [SetUp] public virtual async Task Setup() {