Skip to content

Instantly share code, notes, and snippets.

@kkozmic
Created May 8, 2010 07:35
Show Gist options
  • Save kkozmic/394428 to your computer and use it in GitHub Desktop.
Save kkozmic/394428 to your computer and use it in GitHub Desktop.
Nested closure fluent API for Event Wiring Facility
[Test]
public void Can_specify_multiple_subscribers()
{
container.Register(
Component.For<SimplePublisher>()
.PublishEvent(p => p.Event += null,
x => x.To("foo")
.To<SimpleListener>("bar", 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