Add MediatorExtensions tests and refactor CreateEnvelopeCommand

Introduce MediatorExtensionsTests to cover SendOrThrowAsync and SendOrNotFoundAsync extension methods for IMediator, including edge cases and cancellation. Refactor CreateEnvelopeCommand in Fake.cs to use Authorize(userId) instead of setting UserId directly. Add test stubs for IMediator and IRequest to support isolated testing.
This commit is contained in:
2026-04-08 13:46:27 +02:00
parent 6c54473d5a
commit ce9958a8b1
2 changed files with 297 additions and 6 deletions

View File

@@ -193,13 +193,17 @@ public static class Extensions
#endregion
#region Envelope
public static CreateEnvelopeCommand CreateEnvelopeCommand(this Faker fake, int userId) => new()
public static CreateEnvelopeCommand CreateEnvelopeCommand(this Faker fake, int userId)
{
Message = fake.Lorem.Paragraph(fake.Random.Number(2, 5)),
Title = fake.Lorem.Words(fake.Random.Number(3, 4)).Join(" "),
UserId = userId,
UseSQLExecutor = false
};
var cmd = new CreateEnvelopeCommand
{
Message = fake.Lorem.Paragraph(fake.Random.Number(2, 5)),
Title = fake.Lorem.Words(fake.Random.Number(3, 4)).Join(" "),
UseSQLExecutor = false
};
cmd.Authorize(userId);
return cmd;
}
public static List<CreateEnvelopeCommand> CreateEnvelopeCommands(this Faker fake, params int[] userIDs)
=> Enumerable.Range(0, userIDs.Length)