OpenRasta Mocking HttpContext in unit tests

I am currently writing unit tests for my handler methods using NUnit . I used HttpContext.Current in one of my controller methods, which throws a NULL reference exception in HttpContext.Current when I run test cases for my handler.

Is there any way to make fun of the HttpContext ? or is there any other way to solve this problem.

+4
source share
1 answer

You do not need to access HttpContext.Current . You should be able to use one of the available dependencies that are easily mocked up.

+4
source

Source: https://habr.com/ru/post/1411306/


All Articles