Programming
Mocking IHttpContextAcessor
If you use IHttpContextAccessor in any services then you may need to mock it for unit tests. It’s quite a complicated class but in order to mock the request URL the below code can be used.
If you use IHttpContextAccessor in any services then you may need to mock it for unit tests. It’s quite a complicated class but in order to mock the request URL the below code can be used.
As part of the current project I’m working on we’ve got a service which offloads some email send tasks to a background worker running in Hangfire. Creating the BackgroundJobClient directly in our service was throwing errors and didn’t allow us to test that it had actually been called so we Read more…