Best practices for HttpContext and testable controllers in ASP.Net MVC

后端 未结 2 1748
遇见更好的自我
遇见更好的自我 2021-02-03 11:47

Update:

Based on a couple of the answers I have received, I just want to make clear that I am well aware how to go about mocking HttpContext using a moc

2条回答
  •  醉话见心
    2021-02-03 12:38

    I'm leaning towards HttpContextBase. Mainly because I think it was invented for just this reason: testability. And why reinvent the wheel when there's an acceptable solution already out there.

    If you put a lot of effort into your wrapper classes around HttpContext, you'd end up with something very similar to HttpContextBase...

提交回复
热议问题