public void Publish_Without_Plugins_Test() { // 1) arrange var e = new Event_Mock(); // 2) act eventAggregator.GlobalPublish(e); // 3) assert eventPublisher.AssertWasNotCalled(x => x.Publish(e)); }
public void Publish_Test() { // 1) arrange var e = new Event_Mock(); // 2) act eventAggregator.SubscribePlugin(plugin); eventAggregator.GlobalPublish(e); // 3) assert eventPublisher.AssertWasCalled(x => x.Publish(e)); }
public void Store_And_Publish_Another_Event_Assert_Was_Not_Called_Test() { // 1) arrange var anotherEvent = new Event_Mock(); // 2) act eventConteiner.Store(pluginName, e); eventConteiner.Publish(pluginName, publisher); // 3) assert publisher.AssertWasNotCalled(x => x.Publish(anotherEvent)); }
public void Publish_To_Two_Plugins_Test() { // 1) arrange var e = new Event_Mock(); var anorherPlugin = "plugin"; // 2) act eventAggregator.SubscribePlugin(plugin); eventAggregator.SubscribePlugin(anorherPlugin); eventAggregator.GlobalPublish(e); int repeatTimes = 2; // 3) assert eventPublisher.AssertWasCalled( x => x.Publish(e), option => option.Repeat.Times(repeatTimes)); }
public void Store_Two_Events_And_Publish_Two_Times_Assert_Count_Called_Test() { // 1) arrange var anotherEvent = new Event_Mock(); // 2) act eventConteiner.Store(pluginName, e); eventConteiner.Store(pluginName, anotherEvent); eventConteiner.Publish(pluginName, publisher); eventConteiner.Publish(pluginName, publisher); // 3) assert publisher.AssertWasCalled( example => example.Publish(e), options => options.Repeat.Once() ); }
public void Publish_To_Events_Using_Filed_Publisher_Assert_Count_Queued_Events_Test() { // 1) arrange var eventQueue = new EventQueue(); var eventConteiner = new UnpublishedEventsContainer(eventQueue); var eventAggregator = new EventAggregatorService(errorHandler, publisherCreator, eventConteiner); var anotherEvent = new Event_Mock(); // 2) act eventAggregator.SubscribePlugin(plugin); eventAggregator.GlobalPublish(e); eventAggregator.GlobalPublish(anotherEvent); int actual = eventQueue.GetCount(plugin); int expected = 2; // 3) assert Assert.Equal(expected, actual); }