-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
89 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/NServiceBus.NHibernate.AcceptanceTests/When_using_NHibernate_persistence_without_DTC.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
namespace NServiceBus.AcceptanceTests.Basic | ||
{ | ||
using System; | ||
using NServiceBus.AcceptanceTesting; | ||
using NServiceBus.AcceptanceTests.EndpointTemplates; | ||
using NServiceBus.Persistence.NHibernate; | ||
using NUnit.Framework; | ||
|
||
public class When_using_NHibernate_persistence_without_DTC : NServiceBusAcceptanceTest | ||
{ | ||
[Test] | ||
public void Should_be_able_to_retrieve_database_transaction() | ||
{ | ||
var context = new Context | ||
{ | ||
Id = Guid.NewGuid() | ||
}; | ||
|
||
Scenario.Define(context) | ||
.WithEndpoint<Sender>(b => b.Given((bus, c) => | ||
{ | ||
bus.Send<MyMessage>(m=> | ||
{ | ||
m.Id = c.Id; | ||
}); | ||
})) | ||
.WithEndpoint<Receiver>() | ||
.Done(c => c.Received) | ||
.Run(); | ||
} | ||
|
||
public class Context : ScenarioContext | ||
{ | ||
public bool Received { get; set; } | ||
|
||
public Guid Id { get; set; } | ||
} | ||
|
||
public class Sender : EndpointConfigurationBuilder | ||
{ | ||
public Sender() | ||
{ | ||
EndpointSetup<DefaultServer>() | ||
.AddMapping<MyMessage>(typeof(Receiver)); | ||
} | ||
} | ||
|
||
public class Receiver : EndpointConfigurationBuilder | ||
{ | ||
public Receiver() | ||
{ | ||
EndpointSetup<DefaultServer>(c => | ||
{ | ||
c.Transactions().DisableDistributedTransactions(); | ||
}); | ||
} | ||
|
||
public class MyMessageHandler : IHandleMessages<MyMessage> | ||
{ | ||
public Context Context { get; set; } | ||
|
||
public NHibernateStorageContext StorageContext { get; set; } | ||
|
||
public void Handle(MyMessage message) | ||
{ | ||
if (Context.Id != message.Id) | ||
return; | ||
|
||
Assert.IsNotNull(StorageContext.DatabaseTransaction); | ||
Context.Received = true; | ||
} | ||
} | ||
} | ||
|
||
public class MyMessage : IMessage | ||
{ | ||
public Guid Id { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters