Skip to content

Instantly share code, notes, and snippets.

@msell
Forked from benfoster/gist:2397891
Created April 29, 2014 20:04
Show Gist options
  • Save msell/5d10a142502e8c42e4da to your computer and use it in GitHub Desktop.
Save msell/5d10a142502e8c42e4da to your computer and use it in GitHub Desktop.
[Subject("Domain Events: Raising an event")]
public class Raising_an_event
{
public class When_an_event_publisher_is_not_defined
{
Because of = ()
=> new TestDomainObject().Start();
It Should_do_nothing = () => { };
}
public class When_an_event_publisher_is_defined : WithFakes
{
static Action<IDomainEvent> eventPublisher;
Because of = () =>
{
eventPublisher = An<Action<IDomainEvent>>();
DomainEvents.RegisterEventPublisher(eventPublisher);
new TestDomainObject().Start();
};
It Should_raise_the_event = ()
=> eventPublisher.WasToldTo(x => x.Invoke(Param.IsAny<IDomainEvent>()));
}
public class TestDomainObject
{
public void Start()
{
DomainEvents.Raise(new TestDomainObjectStartedEvent());
}
}
public class TestDomainObjectStartedEvent : IDomainEvent
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment