예제 #1
0
        public void GetAssemblyCachedTest()
        {
            // Check that the same Assembly object is returned.
            Assembly thisAssembly = Assembly.GetExecutingAssembly();

            Assert.AreEqual(thisAssembly, LazyBinding.GetAssembly(thisAssembly.GetName().Name));
        }
예제 #2
0
        public void CreateILogInstanceTest()
        {
            Assembly log4net = LazyBinding.GetAssembly("log4net");
            object   logger  = Log4NetLogger.CreateILogInstance(log4net, "MyLoggerName");

            Assert.IsNotNull(logger);
            Assert.IsTrue(log4net.GetType("log4net.ILog", true).IsAssignableFrom(logger.GetType()));
        }
예제 #3
0
        private Log4NetLogger(object typeOrName)
        {
            // Create an ILog instance using reflection.
            Assembly log4net = LazyBinding.GetAssembly(log4netAssemblyName);
            object   ILog    = CreateILogInstance(log4net, typeOrName);

            // Get a set of function references.
            logInfo           = LazyBinding.CreateMethodDelegate <Action <string> >(ILog, "Info", typeof(string));
            logDebug          = LazyBinding.CreateMethodDelegate <Action <string> >(ILog, "Debug", typeof(string));
            logWarning        = LazyBinding.CreateMethodDelegate <Action <string> >(ILog, "Warn", typeof(string));
            logError          = LazyBinding.CreateMethodDelegate <Action <string> >(ILog, "Error", typeof(string));
            logErrorException = LazyBinding.CreateMethodDelegate <Action <string, Exception> >(
                ILog, "Error", typeof(string), typeof(Exception));
            logIsDebugEnabled = LazyBinding.CreatePropertyGetDelegate <bool>(ILog, "IsDebugEnabled");
        }
예제 #4
0
 public void GetAssemblyUncachedTest()
 {
     // Check that the same Assembly object is returned.
     Assert.IsNotNull(LazyBinding.GetAssembly("log4net"));
 }
예제 #5
0
 public void GetAssemblyNonExistentTest()
 {
     // Ensure that an exception is thrown.
     Assert.Throws <FileNotFoundException>(() => LazyBinding.GetAssembly("non_existing_example_dll"));
 }