Пример #1
0
        public void Store_And_Publish_Assert_Was_Called_Test()
        {
            // 2) act
            eventConteiner.Store(pluginName, e);
            eventConteiner.Publish(pluginName, publisher);

            // 3) assert
            publisher.AssertWasCalled(x => x.Publish(e));
        }
        /// <summary>
        /// Save callback object in dictionary where key is name of appdomain. If in the dictionary
        /// the name exists the item will override.
        /// </summary>
        public void SubscribePlugin(string name)
        {
            lock (syncLock)
            {
                try
                {
                    var callback = publisherCreator.Create();

                    if (pluginSubscribers.ContainsKey(name))
                    {
                        pluginSubscribers[name] = callback;
                        unpublishedEvents.Publish(name, callback);
                    }
                    else
                    {
                        pluginSubscribers.Add(name, callback);
                    }
                }
                catch (Exception ex)
                {
                    errorHandler.OnSubscriptionFailed(name, ex);
                }
            }
        }