Reputation: 4523
I´m trying to use MyProject.config in MSTest. I added this file in "Deployment" (testConfig). What is the best practice to access those fields? Can i build something like Java Properties?
Example:
<host>localhost</host>
<port>0</port>
<user>me</user>
Edit: I have two Unit Test suite . I want to use diferents config files in each test.
Upvotes: 2
Views: 1293
Reputation: 17139
Is the ConfigurationManager.AppSettings
property of any use? Give that a try and see if it works, like this:
string port = System.Configuration.ConfigurationManager.AppSettings("port");
You'd need to refactor your configuration file to be a standard "App.config" file, and you add key/value pairs like this:
<configuration>
<appSettings>
<add key="port" value="80" />
</appSettings>
</configuration>
Upvotes: 1