-
Notifications
You must be signed in to change notification settings - Fork 648
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INeedInitialization not called early enough.
This causes transport, conventions, endpointname and endpointversion not being picked up if configured in INeedInitialization. Fixes #2530
- Loading branch information
John Simons
committed
Oct 27, 2014
1 parent
eec009b
commit 23bab60
Showing
3 changed files
with
107 additions
and
5 deletions.
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
src/NServiceBus.AcceptanceTests/Basic/When_using_ineedinitialization.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,101 @@ | ||
namespace NServiceBus.AcceptanceTests.Basic | ||
{ | ||
using System; | ||
using NServiceBus.AcceptanceTesting; | ||
using NServiceBus.AcceptanceTests.EndpointTemplates; | ||
using NUnit.Framework; | ||
|
||
public class When_using_ineedinitialization : NServiceBusAcceptanceTest | ||
{ | ||
[Test] | ||
public void Should_be_able_to_set_endpoint_name() | ||
{ | ||
var context = new Context(); | ||
|
||
Scenario.Define(context) | ||
.WithEndpoint<Sender>() | ||
.WithEndpoint<Receiver>() | ||
.Done(c => c.WasCalled) | ||
.Run(); | ||
|
||
Assert.True(context.WasCalled, "The message handler should be called"); | ||
} | ||
|
||
public class Context : ScenarioContext | ||
{ | ||
public bool WasCalled { get; set; } | ||
} | ||
|
||
public class Sender : EndpointConfigurationBuilder | ||
{ | ||
public Sender() | ||
{ | ||
EndpointSetup<DefaultServer>(); | ||
} | ||
} | ||
|
||
public class Receiver : EndpointConfigurationBuilder | ||
{ | ||
public Receiver() | ||
{ | ||
EndpointSetup<DefaultServer>() | ||
.AddMapping<SendMessage>(typeof(Sender)); | ||
} | ||
|
||
public class SetEndpointName : INeedInitialization | ||
{ | ||
public void Customize(BusConfiguration config) | ||
{ | ||
config.EndpointName("ineedinitialization_receiver"); | ||
} | ||
} | ||
|
||
public class SendMessageToSender: IWantToRunWhenBusStartsAndStops | ||
{ | ||
public IBus Bus { get; set; } | ||
|
||
public void Start() | ||
{ | ||
Bus.Send(new SendMessage()); | ||
} | ||
|
||
public void Stop() | ||
{ | ||
} | ||
} | ||
} | ||
|
||
[Serializable] | ||
public class SendMessage : ICommand | ||
{ | ||
} | ||
|
||
[Serializable] | ||
public class MyMessage : ICommand | ||
{ | ||
public Guid Id { get; set; } | ||
} | ||
|
||
public class SendMessageHandler : IHandleMessages<SendMessage> | ||
{ | ||
public IBus Bus { get; set; } | ||
|
||
public void Handle(SendMessage message) | ||
{ | ||
Bus.Send("ineedinitialization_receiver", new MyMessage()); | ||
} | ||
} | ||
|
||
public class MyMessageHandler : IHandleMessages<MyMessage> | ||
{ | ||
public Context Context { get; set; } | ||
|
||
public IBus Bus { get; set; } | ||
|
||
public void Handle(MyMessage message) | ||
{ | ||
Context.WasCalled = 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