Wednesday, August 5, 2015

C# - Test - Accessing Web.config in Test Context

When having for instance a unit test in one project and the need to get settings from web.config in another project. We can actually copy the web.config when building the unit test project to retrieve the properties like this. Insert this in Build Events in project settings.
 copy "$(SolutionDir)\Somesite.Web\Web.config" "$(ProjectDir)$(OutDir)$(TargetFileName).config"   

No comments:

Post a Comment