Created
May 8, 2010 07:38
-
-
Save kkozmic/394429 to your computer and use it in GitHub Desktop.
same test, but with static-entry point this time
This file contains hidden or 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
[Test] | |
public void Can_specify_multiple_subscribers() | |
{ | |
container.Register( | |
Component.For<SimplePublisher>() | |
.PublishEvent(p => p.Event += null) | |
.ToSubscribers( | |
EventSubscriber.Named("foo"), | |
EventSubscriber | |
.Named("bar") | |
.HandledBy<SimpleListener>(l => l.OnPublish(null, null))), | |
Component.For<ListenerWithOnEventMethod>().Named("foo"), | |
Component.For<SimpleListener>().Named("bar")); | |
var subscriber1 = container.Resolve<ListenerWithOnEventMethod>("foo"); | |
var subscriber2 = container.Resolve<SimpleListener>("bar"); | |
var publisher = container.Resolve<SimplePublisher>(); | |
publisher.Trigger(); | |
Assert.IsTrue(subscriber1.Listened); | |
Assert.AreSame(publisher, subscriber1.Sender); | |
Assert.IsTrue(subscriber2.Listened); | |
Assert.AreSame(publisher, subscriber2.Sender); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment