public async Task FeedCreatedEvent_should_storeFeed() { //Given var dependencies = new DependencyBundle(); dependencies.FeedStore = A.Fake <IFeedStore>(); var application = new Application(dependencies); var evt = new FeedCreatedEvent() { FeedId = "an-id", FeedName = "a name" }; //When await application.EventBus.PublishEventAsync(evt); //Then A.CallTo(() => dependencies.FeedStore.CreateFeedAsync( A <Feed> .That.Matches(feed => feed.FeedName == evt.FeedName && feed.FeedId == evt.FeedId ) )).MustHaveHappenedOnceExactly(); }
public async Task MailReceived_should_storeFeedEntry() { //Given var dependencies = new DependencyBundle(); dependencies.FeedEntryStore = A.Fake <IFeedEntryStore>(); var application = new Application(dependencies); var id = "this-is-an-id"; var evt = new MailReceivedEvent() { ReceivedOn = id + "@something.com", MailId = "this-is-a-mail-id", Subject = "this is the subject", TextContent = "bla", ReceivedDate = new DateTime(2018, 12, 13, 1, 2, 3) }; //When await application.EventBus.PublishEventAsync(evt); //Then A.CallTo(() => dependencies.FeedEntryStore.CreateFeedEntryAsync( A <FeedEntry> .That.Matches(entry => entry.FeedId == id && entry.FeedEntryId == evt.MailId && entry.PublishedDateTime == evt.ReceivedDate && entry.TextContent == evt.TextContent && entry.Title == evt.Subject ) )).MustHaveHappenedOnceExactly(); }
public async Task Events_should_notBeStoredIfEventStoreIsNull() { //Given var dependencies = new DependencyBundle(); var event1 = A.Fake <IEvent>(); var application = new Application(dependencies); //When await application.EventBus.PublishEventAsync(event1); //Then Assert.Null(dependencies.EventStore); // Just check it didn't throw }
public async Task Events_should_beStoredInEventStore() { //Given var dependencies = new DependencyBundle(); dependencies.EventStore = A.Fake <IEventStore>(); var event1 = A.Fake <IEvent>(); var application = new Application(dependencies); //When await application.EventBus.PublishEventAsync(event1); //Then A.CallTo(() => dependencies.EventStore.StoreEventAsync(event1)).MustHaveHappenedOnceExactly(); }
public Application(DependencyBundle dependencies) { EventBus = new EventBus(dependencies.EventStore); RegisterReactors(dependencies); }
private void RegisterReactors(DependencyBundle dependencies) { EventBus.RegisterReactor(new StoreNewFeedReactor(dependencies.FeedStore)); EventBus.RegisterReactor(new StoreNewEntryReactor(dependencies.FeedEntryStore)); }