From 00fb04dc686037e06d7f035697f04900255bdb76 Mon Sep 17 00:00:00 2001 From: kentdr Date: Mon, 14 Aug 2023 15:42:09 -0400 Subject: [PATCH] Add windows guard to dtc tests --- .../Tx/When_receiving_with_dtc_enabled.cs | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs b/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs index c1f6b047df..6c84a749f5 100644 --- a/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs +++ b/src/NServiceBus.AcceptanceTests/Tx/When_receiving_with_dtc_enabled.cs @@ -1,5 +1,7 @@ namespace NServiceBus.AcceptanceTests.Tx { + using System; + using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Transactions; using AcceptanceTesting; @@ -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"); } }