title: Moq and SqlConnection?
body: <p>I'm writing unit tests for one of our products and have been used Moq to successfully mock connections to Entity Framework. However, I've come across the following method:</p>
  
  <pre><code>public static productValue findValues(string productName, string dbConnectionString)
  {
      try
      {
          SqlConnection conn = new SqlConnection(dbConnectionString);
          conn.Open();
          //Do stuff 
      }
  }
  </code></pre>
  
  <p>Which accesses our database inside that method using a passed connection string. Is it possible to setup a mock DB using Moq and create a connection string which points to the mocked DB? I've trying doing something along the lines of</p>
  
  <pre><code>var mockSqlConnnection = new Mock&lt;SqlConnection&gt;();
  </code></pre>
  
  <p>Though I'm unsure if this is the correct approach, as this would mock the connection itself rather than the DB. </p>