-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'hotfix-4.0.11' into support-4.0
- Loading branch information
Showing
48 changed files
with
939 additions
and
429 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation" /> |
100 changes: 100 additions & 0 deletions
100
...Messaging/When_sending_a_message_that_is_registered_multiple_times_to_another_endpoint.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,100 @@ | ||
namespace NServiceBus.AcceptanceTests.BasicMessaging | ||
{ | ||
using System; | ||
using System.Threading; | ||
using EndpointTemplates; | ||
using AcceptanceTesting; | ||
using NUnit.Framework; | ||
|
||
public class When_sending_a_message_that_is_registered_multiple_times_to_another_endpoint : NServiceBusAcceptanceTest | ||
{ | ||
[Test] | ||
public void First_registration_should_be_the_final_destination() | ||
{ | ||
var context = new Context(); | ||
|
||
Scenario.Define(context) | ||
.WithEndpoint<Sender>(b => b.Given((bus, c) => bus.Send(new MyCommand1()))) | ||
.WithEndpoint<Receiver1>() | ||
.WithEndpoint<Receiver2>() | ||
.Done(c => c.WasCalled1 || c.WasCalled2) | ||
.Run(); | ||
|
||
Assert.IsTrue(context.WasCalled1); | ||
Assert.IsFalse(context.WasCalled2); | ||
} | ||
|
||
public class Context : ScenarioContext | ||
{ | ||
public bool WasCalled1 { get; set; } | ||
public bool WasCalled2 { get; set; } | ||
} | ||
|
||
public class Sender : EndpointConfigurationBuilder | ||
{ | ||
public Sender() | ||
{ | ||
EndpointSetup<DefaultServer>() | ||
.AddMapping<MyCommand1>(typeof(Receiver1)) | ||
.AddMapping<MyCommand2>(typeof(Receiver2)); | ||
} | ||
} | ||
|
||
public class Receiver1 : EndpointConfigurationBuilder | ||
{ | ||
public Receiver1() | ||
{ | ||
EndpointSetup<DefaultServer>(); | ||
} | ||
|
||
public class MyMessageHandler : IHandleMessages<MyBaseCommand> | ||
{ | ||
public Context Context { get; set; } | ||
|
||
public IBus Bus { get; set; } | ||
|
||
public void Handle(MyBaseCommand message) | ||
{ | ||
Context.WasCalled1 = true; | ||
Thread.Sleep(2000); // Just to be sure the other receiver is finished | ||
} | ||
} | ||
} | ||
|
||
public class Receiver2 : EndpointConfigurationBuilder | ||
{ | ||
public Receiver2() | ||
{ | ||
EndpointSetup<DefaultServer>(); | ||
} | ||
|
||
public class MyMessageHandler : IHandleMessages<MyBaseCommand> | ||
{ | ||
public Context Context { get; set; } | ||
|
||
public IBus Bus { get; set; } | ||
|
||
public void Handle(MyBaseCommand message) | ||
{ | ||
Context.WasCalled2 = true; | ||
Thread.Sleep(2000); // Just to be sure the other receiver is finished | ||
} | ||
} | ||
} | ||
|
||
[Serializable] | ||
public abstract class MyBaseCommand : ICommand | ||
{ | ||
} | ||
|
||
[Serializable] | ||
public class MyCommand1 : MyBaseCommand | ||
{ | ||
} | ||
|
||
[Serializable] | ||
public class MyCommand2 : MyBaseCommand | ||
{ | ||
} | ||
} | ||
} |
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
121 changes: 121 additions & 0 deletions
121
src/NServiceBus.AcceptanceTests/PubSub/When_multi_subscribing_to_a_polymorphic_event.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,121 @@ | ||
namespace NServiceBus.AcceptanceTests.PubSub | ||
{ | ||
using System; | ||
using AcceptanceTesting; | ||
using EndpointTemplates; | ||
using Features; | ||
using NUnit.Framework; | ||
|
||
public class When_multi_subscribing_to_a_polymorphic_event : NServiceBusAcceptanceTest | ||
{ | ||
[Test] | ||
public void Both_events_should_be_delivered() | ||
{ | ||
var rootContext = new Context(); | ||
|
||
Scenario.Define(rootContext) | ||
.WithEndpoint<Publisher1>(b => b.Given((bus, context) => Subscriptions.OnEndpointSubscribed(args => | ||
{ | ||
if (args.MessageType.Contains(typeof(IMyEvent).Name)) | ||
{ | ||
context.SubscribedToIMyEvent = true; | ||
} | ||
if (args.MessageType.Contains(typeof(MyEvent2).Name)) | ||
{ | ||
context.SubscribedToMyEvent2 = true; | ||
} | ||
})) | ||
.When(c => c.SubscribedToIMyEvent && c.SubscribedToMyEvent2, bus => bus.Publish(new MyEvent1()))) | ||
.WithEndpoint<Publisher2>(b => b.Given((bus, context) => Subscriptions.OnEndpointSubscribed(args => | ||
{ | ||
if (args.MessageType.Contains(typeof(IMyEvent).Name)) | ||
{ | ||
context.SubscribedToIMyEvent = true; | ||
} | ||
if (args.MessageType.Contains(typeof(MyEvent2).Name)) | ||
{ | ||
context.SubscribedToMyEvent2 = true; | ||
} | ||
})) | ||
.When(c => c.SubscribedToIMyEvent && c.SubscribedToMyEvent2, bus => bus.Publish(new MyEvent2()))) | ||
.WithEndpoint<Subscriber1>(b => b.Given((bus, context) => | ||
{ | ||
bus.Subscribe<IMyEvent>(); | ||
bus.Subscribe<MyEvent2>(); | ||
})) | ||
.Done(c => c.SubscriberGotIMyEvent && c.SubscriberGotMyEvent2) | ||
.Run(); | ||
|
||
Assert.True(rootContext.SubscriberGotIMyEvent); | ||
Assert.True(rootContext.SubscriberGotMyEvent2); | ||
} | ||
|
||
public class Context : ScenarioContext | ||
{ | ||
public bool SubscriberGotIMyEvent { get; set; } | ||
public bool SubscriberGotMyEvent2 { get; set; } | ||
public bool SubscribedToIMyEvent { get; set; } | ||
public bool SubscribedToMyEvent2 { get; set; } | ||
} | ||
|
||
public class Publisher1 : EndpointConfigurationBuilder | ||
{ | ||
public Publisher1() | ||
{ | ||
EndpointSetup<DefaultServer>(); | ||
} | ||
} | ||
|
||
public class Publisher2 : EndpointConfigurationBuilder | ||
{ | ||
public Publisher2() | ||
{ | ||
EndpointSetup<DefaultServer>(); | ||
} | ||
} | ||
|
||
public class Subscriber1 : EndpointConfigurationBuilder | ||
{ | ||
public Subscriber1() | ||
{ | ||
EndpointSetup<DefaultServer>(c => Configure.Features.Disable<AutoSubscribe>()) | ||
.AddMapping<IMyEvent>(typeof(Publisher1)) | ||
.AddMapping<MyEvent2>(typeof(Publisher2)); | ||
} | ||
|
||
public class MyEventHandler : IHandleMessages<IMyEvent> | ||
{ | ||
public Context Context { get; set; } | ||
|
||
public void Handle(IMyEvent messageThatIsEnlisted) | ||
{ | ||
if (messageThatIsEnlisted is MyEvent2) | ||
{ | ||
Context.SubscriberGotMyEvent2 = true; | ||
} | ||
else | ||
{ | ||
Context.SubscriberGotIMyEvent = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
[Serializable] | ||
public class MyEvent1 : IMyEvent | ||
{ | ||
} | ||
|
||
[Serializable] | ||
public class MyEvent2 : IMyEvent | ||
{ | ||
} | ||
|
||
public interface IMyEvent : IEvent | ||
{ | ||
} | ||
} | ||
} |
Oops, something went wrong.