mirror of https://github.com/AMT-Cheif/Stylet.git
Fix bug in EventAggregator
Publishing to multiple channels would only deliver messages to subscribers subcribed to all of those channels, not any of them. Fixes #127
This commit is contained in:
parent
529cd140ee
commit
f5b72703c2
|
@ -183,7 +183,7 @@ namespace Stylet
|
||||||
channels = DefaultChannelArray;
|
channels = DefaultChannelArray;
|
||||||
|
|
||||||
// We're not subscribed to any of the channels
|
// We're not subscribed to any of the channels
|
||||||
if (!channels.All(x => this.channels.Contains(x)))
|
if (!channels.Any(x => this.channels.Contains(x)))
|
||||||
return Enumerable.Empty<HandlerInvoker>();
|
return Enumerable.Empty<HandlerInvoker>();
|
||||||
|
|
||||||
return this.invokers.Where(x => x.CanInvoke(messageType));
|
return this.invokers.Where(x => x.CanInvoke(messageType));
|
||||||
|
|
|
@ -254,6 +254,18 @@ namespace StyletUnitTests
|
||||||
Assert.AreEqual(1, target.ReceivedMessageCount);
|
Assert.AreEqual(1, target.ReceivedMessageCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MessagePublishedToMultipleChannelsGetsDeliveredToSubscribersOnSingleChannels()
|
||||||
|
{
|
||||||
|
var target = new C1();
|
||||||
|
this.ea.Subscribe(target, "C1");
|
||||||
|
|
||||||
|
var message = new M1();
|
||||||
|
this.ea.Publish(message, "C1", "C2");
|
||||||
|
|
||||||
|
Assert.AreEqual(1, target.ReceivedMessageCount);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void PublishingInsideHandlerDoesNotThrow()
|
public void PublishingInsideHandlerDoesNotThrow()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue