title: How to do unit testing on a static method that uses database access?
body: <p>Here's the sample static method, say </p>
  
  <pre><code>public static void UpdateSchedule(int selectedScheduleId)
          {
              using (var dc = new MyDataContext())
              {
                  var selectedSchedule = dc.Schedules.SingleOrDefault(p =&gt; p.ScheduleId == selectedScheduleId)
                  if selectedSchedule != null)
                  {
                      selectedSchedule.Name = name;
                      //and update other properties...
                  }
                  dc.SubmitChanges();
              }
          }
  </code></pre>
  
  <p>So what would be the correct approach to test on methods like this? Is there a way to avoid calling new MyDataContext() as it might increase the execution time of the unit test.</p>
  
  <p>Also, I am using MsTest test framework in VS2012. </p>