title: Use Moq To Override System.Configuration values in C# Test
body: <p>I've been given the task of adding tests to some pre-existing code.  We're trying to keep refactoring to a minimum, so these tests are often a combination of unit / integration tests. </p>
  
  <p>We're also using Moq on this project, which I'm learning on the fly. </p>
  
  <p>My question is, how can I use Moq to override the System.Configuration values (EmailFrom, EmailTo, etc.) in SendEmail below, so I don't have to constantly babysit the System.Configuration values in all our tests System.Configuration Files?   I just want to test we execute the Email.send code </p>
  
  <pre><code>    public clas EmailLogging
      {
         public void SendEmail(string error}
              {
                 string EmailFrom = System.Configuration.ConfigurationSettings.AppSettings["EmailFrom"].ToString();
                 string EmailTo = System.Configuration.ConfigurationSettings.AppSettings["EmailTo"].ToString();
                 string errorLogLocation = System.Configuration.ConfigurationSettings.AppSettings["ErrorLogLocation"].ToString();
                 ...
                 using (SmtpClient client = new SmtpClient())
                  {
                     client.Send(mailMessage);
                  }
  </code></pre>