示例#1
0
 private void Initialize(string name, object fixture)
 {
     this.name     = name;
     this.fixture  = fixture;
     this.fullName = this.fixture.GetType().FullName + "." + name;
     this.method   = Reflect.GetMethod(this.fixture.GetType(), name);
     if (this.method == null)
     {
         this.runState = RunState.NotRunnable;
     }
     else
     {
         IgnoreAttribute ignore = (IgnoreAttribute)Reflect.GetAttribute(this.method, typeof(IgnoreAttribute));
         if (ignore != null)
         {
             this.runState     = RunState.Ignored;
             this.ignoreReason = ignore.Reason;
         }
     }
 }
示例#2
0
        private MethodInfo GetExceptionHandler(Type type, string handlerName)
        {
            if (handlerName == null && Reflect.HasInterface(type, typeof(IExpectException)))
            {
                handlerName = "HandleException";
            }

            if (handlerName == null)
            {
                return(null);
            }

            MethodInfo handler = Reflect.GetMethod(type, handlerName,
                                                   BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static,
                                                   new Type[] { typeof(Exception) });

            if (handler == null)
            {
                Assert.Fail("The specified exception handler {0} was not found", handlerName);
            }

            return(handler);
        }