Esempio n. 1
0
 public static void AddException(string ex, bool log)
 {
     exceptionCount++;
     if (IsFirstError)
     {
         AddLog(@"信息20", "原文件名:" + currentFile, true);
     }
     AddLog(@"错误01", "  第" + ExceptionCount.ToString() + "个格式错误:" + ex, log);
 }
Esempio n. 2
0
        /// <summary>
        /// Records an exception and returns true if the threshold is exceeded for that exception
        /// </summary>
        public bool Record(string testName, Exception ex)
        {
            // Converting from exception to string can be expensive so only do it once and cache the string
            string exceptionString = ex.ToString();

            TraceException(testName, exceptionString);

            // Get the exceptions for the current test case
            ConcurrentDictionary <string, ExceptionCount> exceptionsForTest = _exceptions.GetOrAdd(testName, _ => new ConcurrentDictionary <string, ExceptionCount>());

            // Get the count for the current exception
            ExceptionCount exCount = exceptionsForTest.GetOrAdd(exceptionString, _ => new ExceptionCount());

            // Increment the count
            Interlocked.Increment(ref exCount.Count);

            // If the count is over the threshold, return true
            return(TestMetrics.ExceptionThreshold.HasValue && (exCount.Count > TestMetrics.ExceptionThreshold));
        }