Well, the question speaks for itself. I use to have a static Config class in my project that lazy-load the data from the config file like this :
private static string _foo;
public static string Foo
{
get
{
if (string.IsNullOrEmpty(_foo))
_foo = ConfigurationManager.AppSettings["foo"];
return _foo;
}
set
{
_foo = value;
}
}
That way in my tests I can just set up the Config class the way I want and it won't need to access the filesystem. I also parse to specific types, or to Enums for example.
Do you use a better approach? please share!