private void LoadAssembly(XmlElement el, string currentDirectory)
 {
     if (el.Name == "Assembly" && el.HasAttribute("Path"))
     {
         string   path  = el.GetAttribute("Path");
         FileInfo fInfo = new FileInfo(Path.Combine(currentDirectory, path));
         if (!fInfo.Exists)
         {
             fInfo = new FileInfo(path);
         }
         if (fInfo.Exists)
         {
             try
             {
                 Assembly loadedAssembly      = Assembly.LoadFrom(fInfo.FullName);
                 bool     wasBehaviorAssembly = false;
                 foreach (Type type in loadedAssembly.DefinedTypes)
                 {
                     if (type.BaseType != null && type.BaseType.FullName == "Hansoft.Jean.Behavior.AbstractBehavior")
                     {
                         behaviorTypes.Add(type);
                         wasBehaviorAssembly = true;
                     }
                 }
                 if (!wasBehaviorAssembly)
                 {
                     extensionAssemblies.Add(path);
                 }
             }
             catch (Exception e)
             {
                 logger.Exception("Error in configuration file JeanSettings.xml when loading assembly " + fInfo.FullName + ".", e);
             }
         }
         else
         {
             logger.Error("Error in configuration file JeanSettings.xml. Could not find assembly file: " + path);
         }
     }
     else
     {
         logger.Error("Error in configuration file JeanSettings.xml. Malformed configuration of assemblies: " + el.ToString());
     }
 }
        public void EventLogLogger_ErrorLevel_EventLogEntryTypeUsedTest()
        {
            //Arrange
            var messages = new List <Tuple <string, string, EventLogEntryType> >();
            var logger   = new EventLogLogger("Test")
            {
                WriteEntryToEventLog = (x, y, z) => messages.Add(new Tuple <string, string, EventLogEntryType>(x, y, z))
            };
            var testMessage   = "Test message";
            var testException = new Exception("Test");

            //Act
            logger.IsErrorEnabled = true;
            logger.Error(testMessage);
            logger.Error(testException);
            logger.Error(testMessage, testException);
            //Assert
            Assert.AreEqual(3, messages.Select(x => x).Count(x => x.Item3 == EventLogEntryType.Error));
        }
        public void EventLogLogger_ErrorLog_MessageExposedTest()
        {
            //Arrange
            var messages = new List <Tuple <LogLevel, string, Exception> >();
            var logger   = new EventLogLogger("Test");

            logger.IsErrorEnabled     = true;
            logger.LogMessageHandler += (x, y, z) => messages.Add(new Tuple <LogLevel, string, Exception>(x, y, z));
            var testMessage   = "Test message";
            var testException = new Exception("Test");

            //Act
            logger.Error(testMessage);
            logger.Error(testException);
            logger.Error(testMessage, testException);
            //Assert
            Assert.AreEqual(3, messages.Count);
            Assert.AreEqual(new Tuple <LogLevel, string, Exception>(LogLevel.Error, testMessage, null), messages[0], "Log entry with message was not exposed correctly.");
            Assert.AreEqual(new Tuple <LogLevel, string, Exception>(LogLevel.Error, string.Empty, testException), messages[1], "Log entry with exception was not exposed correctly.");
            Assert.AreEqual(new Tuple <LogLevel, string, Exception>(LogLevel.Error, testMessage, testException), messages[2], "Log entry with message and exception was not exposed correctly.");
        }