[ExpectedException(typeof(InvalidOperationException))] // Normally never use those public async Task TransactionScopeAsync() { var slide = new Slide(title: "Transaction Scope Async"); await slide .Sample(async () => { Assert.Null(Transaction.Current); using (var tx = new TransactionScope()) { Assert.NotNull(Transaction.Current); await SomeMethodInTheCallStackAsync() .ConfigureAwait(false); tx.Complete(); } Assert.Null(Transaction.Current); }); }
public async Task StoreAsyncSupportsAmbientTransactionRollback(DatabaseMode mode) { var slide = new Slide(title: "Store Async supports ambient transactions - rollback"); await slide .Sample(async () => { var database = new Database("StoreAsyncSupportsAmbientTransactionRollback.received.txt", mode); StoringTenSwissGuysInTheDatabase(database); using (var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { await database.SaveAsync().ConfigureAwait(false); // Rollback } database.Close(); }); }