Skip to content

Commit

Permalink
Add windows guard to dtc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kentdr committed Aug 14, 2023
1 parent a5ce55c commit 00fb04d
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace NServiceBus.AcceptanceTests.Tx
{
using System;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Transactions;
using AcceptanceTesting;
Expand All @@ -21,17 +23,26 @@ public async Task Should_enlist_the_receive_in_the_dtc_tx()
Assert.False(context.CanEnlistPromotable, "There should exists a DTC tx");
}


[Test]
public void Basic_assumptions_promotable_should_fail_if_durable_already_exists()
{
//TODO: Is this what we want to do? (only works on windows)
//TransactionManager.ImplicitDistributedTransactions = true;
using (var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))

if (OperatingSystem.IsWindows())
{
Transaction.Current.EnlistDurable(FakePromotableResourceManager.ResourceManagerId, new FakePromotableResourceManager(), EnlistmentOptions.None);
Assert.False(Transaction.Current.EnlistPromotableSinglePhase(new FakePromotableResourceManager()));
// This test only work on Windows
TransactionManager.ImplicitDistributedTransactions = true;
using (var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
Transaction.Current.EnlistDurable(FakePromotableResourceManager.ResourceManagerId, new FakePromotableResourceManager(), EnlistmentOptions.None);
Assert.False(Transaction.Current.EnlistPromotableSinglePhase(new FakePromotableResourceManager()));

tx.Complete();
tx.Complete();
}
}
else
{
Assert.Ignore("Ignoring this test because it requires Windows");
}
}

Expand Down

0 comments on commit 00fb04d

Please sign in to comment.