开发者

Web.Config issue with Unit Testing

开发者 https://www.devze.com 2022-12-28 08:18 出处:网络
I am trying to unit test a lot of my MVC controllers, but unfortunately it keeps failing because it needs a 开发者_开发知识库lot of settings from the web.config..

I am trying to unit test a lot of my MVC controllers, but unfortunately it keeps failing because it needs a 开发者_开发知识库lot of settings from the web.config..

Which I copied over but does not read it, what I'm needing is the membership and rolemanager but I can't just add it to the app.config either, which I've been able to get the connection strings and application settings to work with..

Any idea how to get the web.config to work with MSTest?


Mock it http://www.asp.net/learn/mvc-videos/video-365.aspx


Half of this question has already been answered in another post - Testing Membership provider without ASP.NET. Testing the rolemanager should be possible using the same paradigm.

Note: requiring settings (including the asp.net membership and rolemanager providers) to be retrieved via a config file for test execution means you are writing integration tests instead of unit tests my opinion.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号