C#C
C#3y ago
5 replies
Salah Tanbour

✅ Vertical Slicing with MediatR and Unit Testing

Hello everyone.

I've recently come across Vertical Slice architecture and was amused by it, I think it is a nice approach to build a web api based on features.

I've watched Jimmy Bogard's talk on Vertical slicing with MediatR, but was confused on how to implement unit testing.

I only have a controller which send commands or queries through a mediator object, and a handler that handles this request. In his talk, Jimmy said to not worry about unnecessary abstractions like a Repository for example, we can just pass in the DbContext (in the case of EF Core).

But if that's the case, how can I actually unit test my code when all of my code is inside the handlers since they aren't too big.
image.png
Was this page helpful?