Transactionscope verloren bei der asynchronischen Prüfung

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Transactionscope verloren bei der asynchronischen Prüfung

by Anonymous » 14 Jul 2025, 12:43

Für ein Projekt, an dem ich arbeite, möchte ich TestData vor jedem Test einfügen und dann die Transaktion für den nächsten Test rollen, um mit einem sauberen Schiefer zu beginnen.

Code: Select all

[TestClass]
public class TransactionAsyncTest
{
private TransactionScope? _scope;

[TestInitialize]
public void TestInitialize()
{
_scope = new TransactionScope(TransactionScopeOption.Required, TransactionScopeAsyncFlowOption.Enabled);
}

[TestMethod]
public void Test()
{
Assert.IsNotNull(Transaction.Current);
}

[TestCleanup]
public void TestCleanup()
{
_scope?.Dispose();
}
}

, aber sobald ich die Definition von testinitialize in public async tasks testinitialize () ändere, scheint die Transaktion null in test () zu sein. Gibt es eine Möglichkeit, Testinitialize async zu erstellen, während dieselbe Transaktion (Umfang) in Test ?

Top