Using httpcontext in unit test

后端 未结 4 818
终归单人心
终归单人心 2021-02-13 14:44

I\'m using C#4.0 and i need to unit test a service. The function inside the service returns a path similar to the variable i called expected, this is the path i\'m expecting to

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-13 15:04

    I'm posting this for reference. It's not an easy solution, and talks about Duck Typing (if it quacks..):

    http://haacked.com/archive/2007/08/19/why-duck-typing-matters-to-c-developers.aspx

    http://haacked.com/archive/2007/09/09/ihttpcontext-and-other-interfaces-for-your-duck-typing-benefit.aspx

    It's relevant and worth a read; because there's no IHttpContext it's not possible to create a test environment implementation - until you consider using the Duck Typing library here. Though this is not a direct answer.

    Hope that helps.

提交回复
热议问题