Example #1
0
        public void CanBuildDefaultLogger()
        {
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();

            configurationSource.Add(InstrumentationConfigurationSection.SectionName, new InstrumentationConfigurationSection(true, true, true));

            DefaultCachingEventLogger logger
                = EnterpriseLibraryFactory.BuildUp <DefaultCachingEventLogger>(configurationSource);

            Assert.IsNotNull(logger);
        }
Example #2
0
 private static void TryLogConfigurationError(ConfigurationErrorsException configurationException, string instanceName)
 {
     try
     {
         DefaultCachingEventLogger eventLogger = EnterpriseLibraryFactory.BuildUp <DefaultCachingEventLogger>();
         if (eventLogger != null)
         {
             eventLogger.LogConfigurationError(instanceName, configurationException);
         }
     }
     catch { }
 }
Example #3
0
 private static void TryLogConfigurationError(ActivationException configurationException, string instanceName)
 {
     try
     {
         DefaultCachingEventLogger eventLogger = EnterpriseLibraryContainer.Current.GetInstance <DefaultCachingEventLogger>();
         if (eventLogger != null)
         {
             eventLogger.LogConfigurationError(instanceName, configurationException);
         }
     }
     catch { }
 }
Example #4
0
        public void CanBuildDefaultLogger()
        {
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();

            configurationSource.Add(InstrumentationConfigurationSection.SectionName, new InstrumentationConfigurationSection(true, true, "fooApplicationName"));
            configurationSource.Add(CacheManagerSettings.SectionName, new CacheManagerSettings());

            DefaultCachingEventLogger logger
                =
                    EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource).GetInstance
                    <DefaultCachingEventLogger>();

            Assert.IsNotNull(logger);
        }
Example #5
0
        public void DefaultLoggerFiresWmiEvent()
        {
            DefaultCachingEventLogger logger
                = new DefaultCachingEventLogger(false, true);
            ConfigurationErrorsException exception = new ConfigurationErrorsException(exceptionMessage);

            using (WmiEventWatcher eventListener = new WmiEventWatcher(1))
            {
                logger.LogConfigurationError(instanceName, exception);

                eventListener.WaitForEvents();
                Assert.AreEqual(1, eventListener.EventsReceived.Count);
                Assert.AreEqual("CacheConfigurationFailureEvent", eventListener.EventsReceived[0].ClassPath.ClassName);
                Assert.AreEqual(instanceName, eventListener.EventsReceived[0].GetPropertyValue("InstanceName"));
            }
        }
Example #6
0
        public void DefaultLoggerWritesToEventLog()
        {
            DefaultCachingEventLogger logger
                = new DefaultCachingEventLogger(true, false);
            ConfigurationErrorsException exception = new ConfigurationErrorsException(exceptionMessage);

            using (EventLog eventLog = GetEventLog())
            {
                int eventCount = eventLog.Entries.Count;

                logger.LogConfigurationError(instanceName, exception);

                Assert.AreEqual(eventCount + 1, eventLog.Entries.Count);
                Assert.IsTrue(eventLog.Entries[eventCount].Message.IndexOf(exceptionMessage) > -1);
            }
        }
		public void DefaultLoggerFiresWmiEvent()
		{
			DefaultCachingEventLogger logger
				= new DefaultCachingEventLogger(false, true);
			ConfigurationErrorsException exception = new ConfigurationErrorsException(exceptionMessage);

			using (WmiEventWatcher eventListener = new WmiEventWatcher(1))
			{
				logger.LogConfigurationError(instanceName, exception);

				eventListener.WaitForEvents();
				Assert.AreEqual(1, eventListener.EventsReceived.Count);
				Assert.AreEqual("CacheConfigurationFailureEvent", eventListener.EventsReceived[0].ClassPath.ClassName);
				Assert.AreEqual(instanceName, eventListener.EventsReceived[0].GetPropertyValue("InstanceName"));
			}
		}
		public void DefaultLoggerWritesToEventLog()
		{
			DefaultCachingEventLogger logger
				= new DefaultCachingEventLogger(true, false);
			ConfigurationErrorsException exception = new ConfigurationErrorsException(exceptionMessage);

			using (EventLog eventLog = GetEventLog())
			{
				int eventCount = eventLog.Entries.Count;

				logger.LogConfigurationError(instanceName, exception);

				Assert.AreEqual(eventCount + 1, eventLog.Entries.Count);
				Assert.IsTrue(eventLog.Entries[eventCount].Message.IndexOf(exceptionMessage) > -1);
			}
		}
        public void DefaultLoggerWritesToEventLog()
        {
            DefaultCachingEventLogger logger
                = new DefaultCachingEventLogger(true);
            ConfigurationErrorsException exception = new ConfigurationErrorsException(exceptionMessage);

            using (var eventLog = new EventLogTracker(GetEventLog()))
            {
                logger.LogConfigurationError(instanceName, exception);

                var newEntries = from entry in eventLog.NewEntries()
                                 where entry.Message.IndexOf(exceptionMessage) > -1
                                 select entry;

                Assert.AreEqual(1, newEntries.ToList().Count);
            }
        }
Example #10
0
        public void DefaultLoggerWritesToEventLog()
        {
            DefaultCachingEventLogger logger
                = new DefaultCachingEventLogger(true);
            ConfigurationErrorsException exception = new ConfigurationErrorsException(exceptionMessage);

            using (var eventLog = new EventLogTracker(GetEventLog()))
            {
                logger.LogConfigurationError(instanceName, exception);

                var newEntries = from entry in eventLog.NewEntries()
                                 where entry.Message.IndexOf(exceptionMessage) > -1
                                 select entry;

                Assert.AreEqual(1, newEntries.ToList().Count);
            }
        }