-
-
Save msell/5d10a142502e8c42e4da to your computer and use it in GitHub Desktop.
This file contains 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
[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