示例#1
0
 private void InternalMatching(string pattern, RunCode callback)
 {
     Set(true);
     lastWarning = null;
     callback.Invoke();
     Assert.IsTrue(warningOccurred, "Expected a warning, but did not get it");
     if (warningOccurred && pattern != null)
     {
         Assert.IsTrue(Regex.IsMatch(lastWarning, pattern), lastWarning + " does not match pattern " + pattern);
     }
     Set(false);
 }
        /// <summary>
        /// Starts the Stop watch and runs the code that has been passed in to be run
        /// Callback will return with results
        /// </summary>
        /// <param name="codeToRun"> code to run. This is the code inside a method being passed to the tool to form an analysis of the performance
        /// [It is required that you fill the to paramaters into you delegate, null is excepted]</param>
        /// <param name="param1"> paramater 1 that may be sent to the method [null if you are not going to need paramaters]</param>
        /// <param name="param2">parameter 2 that may be sen to the method [null if you are not going to need paramaters]</param>
        /// <returns></returns>
        public object StartStopWatch(RunCode codeToRun, object param1, object param2, bool addUserFriendlyResult)
        {
            _stopwatch.Start();
            _timeStarted = DateTime.Now.TimeOfDay;

            object codeReturned = codeToRun(param1, param2);

            StopStopWatch(addUserFriendlyResult);

            return codeReturned;
        }
示例#3
0
 /// <summary>
 /// Declare that a specific warning is expected to be generated during the specified code.
 /// </summary>
 /// <param name="pattern">Pattern to match the warning against; if there is no match, the test fails.</param>
 /// <param name="code">Code which is expected to generate a matching warning.</param>
 public static void Matching(string pattern, RunCode code)
 {
     Initialize();
     listener.InternalMatching(pattern, code);
 }