josephwoodward / GlobalExceptionHandlerDotNet

Exception handling as a convention in the ASP.NET Core request pipeline
MIT License
272 stars 32 forks source link

How to handle the response in unit test cases? #46

Open srivatsahg opened 2 years ago

srivatsahg commented 2 years ago

Hello How can I handle the exceptions deliberately thrown from the controller using MediatR in UT cases

Ex: This code snippet expects an ArgumentException from the controller side

command.CustomerProfileId = id; await _mediator.Send(command); return Ok();

The line await _mediator.Send(command); throws NullReference Exception.