Ejemplo n.º 1
0
 public void Execute()
 {
     foreach (var type in testAssembly.GetTypes())
     {
         var index = type.Name.LastIndexOf("Tests");
         if (index > -1 && index == type.Name.Length - 5)
         {
             var methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public);
             var instance = type.GetConstructor(new Type[] { }).Invoke(new object[] { });
             foreach (var method in methods)
             {
                 if (method.ReturnType == typeof(void))
                 {
                     var result = new TestResult { TestClass = type.Name, TestMethod = method.Name, Message = string.Empty };
                     try
                     {
                         method.Invoke(instance, new object[] { });
                         result.Pass = true;
                         Debug.Print("PASS " + type.Name + "." + method.Name);
                     }
                     catch (AssertException ex)
                     {
                         result.Pass = false;
                         result.Message = ex.Message;
                         Debug.Print("FAIL " + type.Name + "." + method.Name + ": " + ex.Message);
                     }
                     catch (Exception ex)
                     {
                         result.Pass = false;
                         result.Message = ex.ToString();
                         Debug.Print("FAIL " + type.Name + "." + method.Name + " - Threw Exception:" + ex.Message);
                     }
                     OnTestCompleted(result);
                 }
             }
         }
     }
     OnAllTestsCompleted();
 }
Ejemplo n.º 2
0
 public TestCompletedEventArgs(TestResult result)
 {
     Result = result;
 }
Ejemplo n.º 3
0
 protected virtual void OnTestCompleted(TestResult result)
 {
     if (TestCompleted != null) TestCompleted(this, new TestCompletedEventArgs(result));
 }