-
Notifications
You must be signed in to change notification settings - Fork 36
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
4 changed files
with
62 additions
and
6 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
55 changes: 55 additions & 0 deletions
55
src/NServiceBus.SqlServer.AcceptanceTests/When_processing_messages.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,55 @@ | ||
namespace NServiceBus.AcceptanceTests.Basic | ||
{ | ||
using System; | ||
using NServiceBus.AcceptanceTesting; | ||
using NServiceBus.AcceptanceTests.EndpointTemplates; | ||
using NServiceBus.Transports.SQLServer; | ||
using NUnit.Framework; | ||
|
||
public class When_processing_messages : NServiceBusAcceptanceTest | ||
{ | ||
[Test] | ||
public void Should_allow_injecting_the_storage_context() | ||
{ | ||
var context = new Context(); | ||
|
||
Scenario.Define(context) | ||
.WithEndpoint<Endpoint>(b => b.Given(bus => bus.SendLocal(new TestMessage()))) | ||
.Done(c => c.Done) | ||
.Run(); | ||
|
||
Assert.True(context.ContextInjected); | ||
} | ||
|
||
public class Context : ScenarioContext | ||
{ | ||
public bool Done { get; set; } | ||
public bool ContextInjected { get; set; } | ||
} | ||
|
||
|
||
[Serializable] | ||
public class TestMessage : IMessage { } | ||
|
||
public class Endpoint : EndpointConfigurationBuilder | ||
{ | ||
public Endpoint() | ||
{ | ||
EndpointSetup<DefaultServer>(b => b.Transactions().DisableDistributedTransactions()); | ||
} | ||
|
||
class Handler : IHandleMessages<TestMessage> | ||
{ | ||
public Context Context { get; set; } | ||
public SqlServerStorageContext StorageContext { get; set; } | ||
|
||
public void Handle(TestMessage message) | ||
{ | ||
Context.ContextInjected = StorageContext != null && StorageContext.Connection != null && StorageContext.Transaction != null; | ||
Context.Done = true; | ||
} | ||
} | ||
} | ||
|
||
} | ||
} |
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