-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make SendOnlyInterface a separate concept entirely
- Loading branch information
1 parent
f70993a
commit 137b8b9
Showing
7 changed files
with
128 additions
and
39 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
83 changes: 83 additions & 0 deletions
83
...eBus.Router.AcceptanceTests/SingleRouter/When_forwarding_a_message_via_sendonly_router.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,83 @@ | ||
using System.Threading.Tasks; | ||
using NServiceBus.AcceptanceTesting; | ||
using NServiceBus.AcceptanceTests; | ||
using NServiceBus.AcceptanceTests.EndpointTemplates; | ||
using NUnit.Framework; | ||
|
||
namespace NServiceBus.Router.AcceptanceTests.SingleRouter | ||
{ | ||
using AcceptanceTesting.Customization; | ||
|
||
[TestFixture] | ||
public class When_forwarding_a_message_via_sendonly_router : NServiceBusAcceptanceTest | ||
{ | ||
[Test] | ||
public async Task Should_deliver_the_message() | ||
{ | ||
var result = await Scenario.Define<Context>() | ||
.WithRouter("Router", cfg => | ||
{ | ||
cfg.AddInterface<TestTransport>("Left", t => t.BrokerAlpha()).InMemorySubscriptions(); | ||
cfg.AddSendOnlyInterface<TestTransport>("Right", t => t.BrokerBravo()).InMemorySubscriptions(); | ||
|
||
cfg.UseStaticRoutingProtocol().AddForwardRoute("Left", "Right"); | ||
}) | ||
.WithEndpoint<Sender>(c => c.When(s => s.Send(new MyRequest()))) | ||
.WithEndpoint<Receiver>() | ||
.Done(c => c.RequestReceived) | ||
.Run(); | ||
|
||
Assert.IsTrue(result.RequestReceived); | ||
} | ||
|
||
class Context : ScenarioContext | ||
{ | ||
public bool RequestReceived { get; set; } | ||
} | ||
|
||
class Sender : EndpointConfigurationBuilder | ||
{ | ||
public Sender() | ||
{ | ||
EndpointSetup<DefaultServer>(c => | ||
{ | ||
var routing = c.UseTransport<TestTransport>().BrokerAlpha().Routing(); | ||
var bridge = routing.ConnectToRouter("Router"); | ||
bridge.RouteToEndpoint(typeof(MyRequest), Conventions.EndpointNamingConvention(typeof(Receiver))); | ||
}); | ||
} | ||
} | ||
|
||
class Receiver : EndpointConfigurationBuilder | ||
{ | ||
public Receiver() | ||
{ | ||
EndpointSetup<DefaultServer>(c => | ||
{ | ||
//No bridge configuration needed for reply | ||
c.UseTransport<TestTransport>().BrokerBravo(); | ||
}); | ||
} | ||
|
||
class MyRequestHandler : IHandleMessages<MyRequest> | ||
{ | ||
Context scenarioContext; | ||
|
||
public MyRequestHandler(Context scenarioContext) | ||
{ | ||
this.scenarioContext = scenarioContext; | ||
} | ||
|
||
public Task Handle(MyRequest request, IMessageHandlerContext context) | ||
{ | ||
scenarioContext.RequestReceived = true; | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} | ||
|
||
class MyRequest : IMessage | ||
{ | ||
} | ||
} | ||
} |
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
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
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