public void Log_WhenListenerRegisteredThenUnregistered_DoesNotCallListener()
        {
            DispatchLogger logger = new DispatchLogger();
            ILogger listener = MockRepository.GenerateMock<ILogger>();
            var ex = new ExceptionData(new Exception("foo"));
            logger.AddLogListener(listener);
            logger.RemoveLogListener(listener);

            logger.Log(LogSeverity.Important, "Message", ex);

            listener.VerifyAllExpectations();
        }
        public void Log_WhenEventHandlerRegistered_FiresEvent()
        {
            LogEntrySubmittedEventArgs receivedEvent = null;
            DispatchLogger logger = new DispatchLogger();
            logger.LogMessage += (sender, e) => receivedEvent = e;

            logger.Log(LogSeverity.Important, "Message", new Exception("foo"));

            Assert.IsNotNull(receivedEvent);
            Assert.AreEqual(LogSeverity.Important, receivedEvent.Severity);
            Assert.AreEqual("Message", receivedEvent.Message);
            Assert.AreEqual("foo", receivedEvent.ExceptionData.Message);
        }
        public void RemoveLogListener_WhenLoggerIsNull_Throws()
        {
            DispatchLogger logger = new DispatchLogger();

            Assert.Throws<ArgumentNullException>(() => logger.RemoveLogListener(null));
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes the runtime.
        /// </summary>
        /// <param name="registry">The registry.</param>
        /// <param name="pluginLoader">The plugin loader.</param>
        /// <param name="assemblyLoader">The assembly loader.</param>
        /// <param name="runtimeSetup">The runtime setup options.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="registry"/>,
        /// <paramref name="pluginLoader"/>, <paramref name="assemblyLoader"/> or
        /// <paramref name="runtimeSetup" /> is null.</exception>
        public DefaultRuntime(IRegistry registry, IPluginLoader pluginLoader,
            IAssemblyLoader assemblyLoader, RuntimeSetup runtimeSetup)
        {
            if (registry == null)
                throw new ArgumentNullException("registry");
            if (pluginLoader == null)
                throw new ArgumentNullException("pluginLoader");
            if (assemblyLoader == null)
                throw new ArgumentNullException(@"assemblyResolverManager");
            if (runtimeSetup == null)
                throw new ArgumentNullException(@"runtimeSetup");

            this.registry = registry;
            this.pluginLoader = pluginLoader;
            this.assemblyLoader = assemblyLoader;
            this.runtimeSetup = runtimeSetup.Copy();

            dispatchLogger = new DispatchLogger();
            pluginDirectories = new List<string>();
            conditionContext = new RuntimeConditionContext();
        }