4

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.

prashant
  • 2,181
  • 2
  • 22
  • 37
  • 1
    Why do you need to access HttpContext.Current directly? OpenRasta provides abstractions over most things so you should be able to take one of its interfaces as a dependency and get to what you need through that instead. – Garry Shutler May 09 '12 at 08:34

1 Answers1

4

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

Garry Shutler
  • 32,260
  • 12
  • 84
  • 119