Ir al contenido

Buscar en el Ecosistema EricksonLopez.*

Escribe el nombre de una librería, ID de paquete NuGet, tipo .NET o concepto arquitectónico para buscar en el portal.

Guías y Recetas — Mediator

Patrones prácticos para behaviors sin asignaciones en heap y pruebas unitarias aisladas.

using System.Threading;
using System.Threading.Tasks;
using EricksonLopez.Mediator;
namespace Example.MediatorRecipes;
public sealed class TimingBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
where TRequest : notnull
{
public async ValueTask<TResponse> Handle<TNext>(
TRequest request,
TNext next,
CancellationToken cancellationToken)
where TNext : struct, INext<TResponse>
{
return await next.InvokeAsync();
}
}

Utiliza EricksonLopez.Mediator.Testing.FakeMediator en pruebas de presentación o aplicación para simular respuestas (SetupCommand, SetupQuery) y verificar despachos (ShouldHaveReceived<T>(), ReceivedCount<T>()).