title: Using xUnit.net AutoRollback and Multi Threading
body: <p>I am trying to write a test case using xUnit.net and the AutoRollback attribute provided by the xunit extensions.</p>
  
  <p>My test case goes like this</p>
  
  <pre><code>[Fact, AutoRollback]&lt;br&gt;
  public void TestCase()&lt;br&gt;
  {
  
      // insert into data table
      repository.Insert(data);
  
      // spawn a new thread and read data which you just inserted in the data table
      Task.Factory.StartNew(action_to_read_data);
  }
  </code></pre>
  
  <p>This test case fails and throws a connection timeout exception while reading the data in the new thread. The problem I have found is that the test case starts a transaction because of the AutoRollback attribute and while Inserting the data it locks the table for rollback at the end. The new thread spawned by the test case cannot read data from the same table because it is locked by the parent thread. I can read the data in the same thread though.</p>
  
  <p>Anyone have a solution? I want to run multiple threads reading the data inserted above.</p>