Search code examples
c#nunitopenrasta

OpenRasta Mocking HttpContext in Unit Tests


Currently i am writing a unit tests for my handler methods using NUnit.I have used HttpContext.Current in one of my Controller Methods which throws NULL reference exception at HttpContext.Current when i execute test cases for my handler.

Is there any way i can mock HttpContext?or is there any other way to solve this issue.


Solution

  • You should not need to access HttpContext.Current directly. You should be able to use one of the available dependencies which are easily mockable.