Ejemplo n.º 1
0
        public void Test_LogHelper_RetryLog3()
        {
            Hashtable hashTable = typeof(WriterFactory).InvokeMember("s_writerTable",
                                                                     BindingFlags.GetField | BindingFlags.Static | BindingFlags.NonPublic,
                                                                     null, null, null) as Hashtable;

            string key = typeof(WriterFactory).InvokeMember("ExceptionWriterKey",
                                                            BindingFlags.GetField | BindingFlags.Static | BindingFlags.NonPublic,
                                                            null, null, null) as string;

            object currentValue = hashTable[key];

            // 设置成一个新的Writer
            hashTable[key] = typeof(ErrorWriter);

            _lastException = null;

            List <Exception> list = new List <Exception>();

            list.Add(new NotImplementedException());

            CacheQueue <ExceptionInfo> queue = new CacheQueue <ExceptionInfo>();
            MethodInfo method = queue.GetType().GetMethod("ProcessFlushException", BindingFlags.Instance | BindingFlags.NonPublic);

            try {
                method.Invoke(queue, new object[] { list });
            }
            finally {
                // 还原重试的Writer
                hashTable[key] = currentValue;
            }

            Assert.IsNotNull(_lastException);
        }
Ejemplo n.º 2
0
        private List <PerformanceInfo> GetQueueData()
        {
            MethodInfo getCacheQueueMethod  = typeof(LogHelper).GetMethod("GetCacheQueue", BindingFlags.Static | BindingFlags.NonPublic);
            MethodInfo getCacheQueueMethod2 = getCacheQueueMethod.MakeGenericMethod(typeof(PerformanceInfo));

            CacheQueue <PerformanceInfo> queue = getCacheQueueMethod2.Invoke(null, null) as CacheQueue <PerformanceInfo>;

            FieldInfo field = queue.GetType().GetField("_list", BindingFlags.Instance | BindingFlags.NonPublic);

            return(field.GetValue(queue) as List <PerformanceInfo>);
        }
Ejemplo n.º 3
0
        public void Test_LogHelper_RetryLog()
        {
            List <Exception> list = new List <Exception>();

            list.Add(new NotImplementedException());

            CacheQueue <ExceptionInfo> queue = new CacheQueue <ExceptionInfo>();
            MethodInfo method = queue.GetType().GetMethod("ProcessFlushException", BindingFlags.Instance | BindingFlags.NonPublic);

            method.Invoke(queue, new object[] { list });
        }