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:
Antony Male 2020-06-20 12:05:15 +01:00
parent 529cd140ee
commit f5b72703c2
2 changed files with 13 additions and 1 deletions

View File

@ -183,7 +183,7 @@ namespace Stylet
channels = DefaultChannelArray;
// 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 this.invokers.Where(x => x.CanInvoke(messageType));

View File

@ -254,6 +254,18 @@ namespace StyletUnitTests
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]
public void PublishingInsideHandlerDoesNotThrow()
{