Testing the Application Layer requires isolation. We need to verify that the 'Service' coordinates the domain and infrastructure correctly.
When testing a Use Case (like CreateOrderHandler), you mock the IOrderRepository and IEmailService. You check that the handler calls repository.Add() and then unitOfWork.SaveChangesAsync(). This verifies that the 'Recipe' of the use case is correct without needing a real database or a real email server.
If you're using MediatR Behaviors for logging or validation, you can test these in isolation too. This ensures your cross-cutting concerns are working globally without having to repeat their tests for every single handler.
Q: "Moq or NSubstitute?"
Architect Answer: "Both are excellent. **NSubstitute** has a cleaner, more readable syntax (e.g., repo.Received().Add(item)) while **Moq** is the veteran with more advanced features. For Clean Architecture, readability is king, so NSubstitute is often the preferred choice for senior .NET teams today."