How to use web.config when unit testing an asp .net application

后端 未结 6 1290
我寻月下人不归
我寻月下人不归 2020-12-08 01:55

I am starting out with unit testing, I have a method that uses the web.config for a connection string.

I was hoping to be able to use

[DeploymentItem         


        
6条回答
  •  天涯浪人
    2020-12-08 02:17

    I would recommend abstracting the configuration reading part, so that it could be mocked. Something like this, see Jon_Lindeheim's reply How to read Web.Config file while Unit Test Case Debugging?

提交回复
热议问题