title: Unit test passes when in debug but fails when run
body: <p>A search method returns any matching Articles and the most recent Non-matching articles up to a specified number.</p>
  
  <p>Prior to being returned, the IsMatch property of the matching articles is set to true as follows:</p>
  
  <p>articles = matchingArticles.Select(c => { c.IsMatch = true; return c; }).ToList();</p>
  
  <p>In a test of this method, </p>
  
  <pre><code>    [Test]
      public void SearchForArticle1Returns1MatchingArticleFirstInTheList()
      {
          using (var session = _sessionFactory.OpenSession())
          {
              var maxResults = 10;
              var searchPhrase = "Article1";
              IArticleRepository articleRepository = new ArticleRepository(session);
              var articles = articleRepository.GetSearchResultSet(searchPhrase, maxResults);
              Assert.AreEqual(10, articles.Count);
              Assert.AreEqual(1, articles.Where(a =&gt; a.Title.Contains(searchPhrase)).Count());
              var article = articles[0];
              Assert.IsTrue(article.Title.Contains(searchPhrase));
              Assert.IsTrue(article.IsMatch);
          }
      }
  </code></pre>
  
  <p>All assertions pass when the test is run in debug, however the final assertion fails when the test is run in release:</p>
  
  <p>Expected: True
    But was:  False</p>
  
  <p>In the app itself the response is correct.</p>
  
  <p>Any ideas as to why this is happening?</p>
  
  <p>Edit:</p>
  
  <p>I figured out what the problem is. It's essentially a race condition. When I am setting up the tests, I am dropping the db table, recreating it and populating it with the test data. Since the search relies on Full Text search, I am creating a text index on the relevant columns and setting it to auto populate. When this is run in debug, there appears to be sufficient time to populate the text index and the search query returns matches. When I run the test I don't think the index has been populated in time, no matches are returned and the test fails. It's similar to issues with datetimes. If I put a delay between creating the catalog and running the test the test passes.</p>