Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is MSDTC behaving inconsistently while unit-testing with mstest?
    text
    copied!<p>I experience a strange issue while testing my Nhibernate repositories.</p> <p>I have 10 unit-tests like the ones below. Everytime a run them in a batch the first fails and the rest succeeds. If a run them one by one they all fail. If a restart MSDTC before my testrun it sometimes behaves like before and sometimes all tests succeeds. I can´t find a pattern why it behaves like that.</p> <p>I want the transaction to rollback so that a start with a clean DB for every test, therefore the transaction disposal.</p> <p>The test/tests are failing due to this error:</p> <blockquote> <p>System.Data.SqlClient.SqlException: MSDTC on server 'MYCOMPUTERNAME\SQLEXPRESS' is unavailable.</p> </blockquote> <p>My tests looks like this:</p> <pre><code>[TestInitialize] public void MyTestInitialize() { _transactionScope = new TransactionScope(); } [TestCleanup] public void MyTestCleanup() { if (_transactionScope != null) { _transactionScope.Dispose(); _transactionScope = null; } } [TestMethod] [TestCategory("RepositoryTests")] public void RepositoryCanSaveAProduct() { var platform = ProductObjectMother.CreatePlatform("100010", "Supplier 10"); var mainsegment = ProductObjectMother.CreateMainSegment("123"); var application = ProductObjectMother.CreateApplication("Foo"); var productfamily = ProductObjectMother.CreateProductFamily("X99"); Engine i = ProductObjectMother.CreateEngine(platform, productfamily, application, mainsegment); var repository = new ProductRepository(); repository.Save(i); repository.Flush(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload