title: Unit Test inconsistent pass or fail result
body: <p>One of my unit tests seems to randomly pass or fail when I run it. The only thing that makes sense to me for why this is happening is if the data in the database is getting into a different state each time the test is ran, but I use transactions to rollback the database in each test - unless it's not working right. Here's my base unit test class and the unit test class that's having the problem. Can you see anything I might be missing or what else I should look for?</p>
  
  <p>This happens with TestDriven.Net <em>and</em> the Visual Studio Unit Test Framework. </p>
  
  <pre><code>Partial Public MustInherit Class TestBase
  
      Private _scope As Transactions.TransactionScope
  
      &lt;DebuggerStepThrough()&gt; _
      &lt;TestInitialize()&gt; _
      Public Sub Setup()
  
              //'Start the Distribution Transaction Coordinator, if it's not already running.
              Using dtcService As New System.ServiceProcess.ServiceController("Distributed Transaction Coordinator", My.Computer.Name)
                      If dtcService.Status = ServiceProcess.ServiceControllerStatus.Stopped Then
                              dtcService.Start()
                      End If
              End Using
  
              _scope = New TransactionScope(TransactionScopeOption.RequiresNew, New TimeSpan(0))
      End Sub
  
      &lt;DebuggerStepThrough()&gt; _
      &lt;TestCleanup()&gt;
      Public Sub Teardown()
          If _scope IsNot Nothing Then
              _scope.Dispose()
          End If
      End Sub
  
      &lt;System.Diagnostics.DebuggerStepThrough()&gt; _
      Public Shared Function ExecSql(ByVal sql As String) As System.Data.DataTable
  
          Dim connStr = GlobalSettings.GetConnectionString()
          Using conn As New System.Data.SqlClient.SqlConnection(connStr)
              conn.Open()
  
              Dim cmd As New System.Data.SqlClient.SqlCommand(sql.ToString, conn)
              Dim adapter As System.Data.SqlClient.SqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter(cmd)
              Dim dt As System.Data.DataTable = New System.Data.DataTable
              adapter.Fill(dt)
  
              Return dt
  
              If conn.State &lt;&gt; System.Data.ConnectionState.Closed Then
                  conn.Close()
              End If
              conn.Dispose()
          End Using
      End Function
  End Class
  </code></pre>
  
  <p>And here's my unit test:</p>
  
  <pre><code>Partial Public Class CampaignEmailSendLimitServiceTests
      Inherits TestBase
  
      Private _service = ServiceManager.Current.MyService
  
      &lt;TestMethod()&gt; _
      Public Sub MyTest()
          //' Set the pre-test condition.
          ExecSql("update base.dbo.tblTableA set someDate = '2010-06-28' where id = 56937 ")
  
          //' Run the service
          _service.Process()
  
         //' Verify the expected result
         Dim dt = ExecSql("select deliveryDate from tblTableB ")
         Assert.AreEqual(False, dt.Rows(0).IsNull("deliveryDate"))
  
      End Sub
  End Class
  </code></pre>