예제 #1
0
        /// <summary>
        /// Gets a custom <see cref="ICallerContext"/> for a test method (specified by <paramref name="testMethodName"/>)
        /// or the <see cref="DefaultCallerContext"/> if no custom context was defined.
        /// </summary>
        /// <param name="testMethodName"> The name of the method under test. </param>
        /// <returns> The specified method's <see cref="ICallerContext"/>. </returns>
        internal static ICallerContext GetCallerContextFor(string testMethodName)
        {
            if (CustomCallerContexts.TryGetValue(testMethodName, out ICallerContext context))
            {
                return(context);
            }

            return(DefaultCallerContext);
        }
예제 #2
0
 /// <summary>
 /// Set a custom <see cref="ICallerContext"/> for a test method (specified by <paramref name="testMethodName"/>).
 /// </summary>
 /// <param name="testMethodName"> The name of the method under test. </param>
 /// <param name="context"> The method's custom <see cref="ICallerContext"/>. </param>
 internal static void SetCallerContextFor(string testMethodName, ICallerContext context)
 {
     if (CustomCallerContexts.ContainsKey(testMethodName))
     {
         CustomCallerContexts[testMethodName] = context;
     }
     else
     {
         CustomCallerContexts.Add(testMethodName, context);
     }
 }
예제 #3
0
 /// <summary>
 /// Removes a custom <see cref="ICallerContext"/> for a test method (specified by <paramref name="testMethodName"/>)
 /// and use the <see cref="DefaultCallerContext"/> instead.
 /// </summary>
 /// <param name="testMethodName"> The name of the method under test. </param>
 internal static void ResetCallerContextFor(string testMethodName)
 {
     CustomCallerContexts.Remove(testMethodName);
 }