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.
精彩评论