I'm using strongly typed configuration sections in my project and want to unit test a particular area which throws an exception when a setting isn't set-up correctly.
A snippet of the configuration class:
public class EmailSettings : SerializableConfigurationSection, IEmailSettings
{
    [ConfigurationProperty("from", IsRequired = true)]
    public string From
    {
      get
      {
        ...
      }
      set
      {
        ...
      }
    }
    ...
}
Sample test method:
[TestMethod]
public void something_describing_this_test()
{
  EmailSettings settings = new EmailSettings();
  settings.From;
}
I expect that SerializableConfigurationSection and its inners are looking for a web.config (or similar) to read xml config from.
How can I get in the middle and 'mock' the configuration to enable me to pipe custom values to test for certain conditions?  This question (using ConfigurationManager methods) appears to do it via a physical config file in the assembly - is this the only way or can I get in there programmatically?
 
     
    