Reputation: 25349
I am playing around with the Clean Architecture by Ardalis.
Can someone please explain what this NoOpMediator role in Unit testing?
using System.Runtime.CompilerServices;
using MediatR;
namespace Clean.Architecture.UnitTests;
public class NoOpMediator : IMediator
{
public Task Publish(object notification, CancellationToken cancellationToken = default)
{
return Task.CompletedTask;
}
...
...
}
It does not seem to do anything. For four of its methods it returns Task.CompletedTask. And for the rest of the two it returns Task.FromResult<object?>(default)
Further more in the BaseEfRepoTestFixture class here, there is no configuration of Mock object. Bit misty.
Also noted that this is configured in CustomWebApplicationFactory way down here.
services.AddScoped<IMediator, NoOpMediator>();
Even if I comment out that line, the tests still pass.
There should be an example test to show how this works.
Upvotes: 0
Views: 170