private void HandleExceptionDuringTestMethod(TestFixture testFixture, MethodInfo methodInfo, Type exceptionType, Exception exception)
 {
     if ((exceptionType != null && exception.InnerException != null && exception.InnerException.GetType() != exceptionType))
     {
         testFixture.Failed(string.Format("Unexpected exception expected {0} but was {1}... {2}", exceptionType.Name, exception.InnerException.GetType().Name, exception.Message));
     }
     else if(exceptionType != null && exception.InnerException != null && exception.InnerException.GetType() == exceptionType)
     {
         testFixture.Passed(methodInfo.Name);
     }
     else
     {
         testFixture.Failed(string.Format("Unexpected {0}... {1}", exception.GetType().Name, exception.Message));
     }
 }
 private void SetFixtureToFailed(string methodName, TestFixture testFixture, Exception exception)
 {
     testFixture.SetClassName(testFixture.GetType().Name);
     testFixture.SetMethodName(methodName);
     testFixture.Failed("An exception occured during " + methodName + "..." + exception.Message);
 }
 private void FailTestOnExpectedExceptionNotThrown(TestFixture testFixture, Type exceptionType)
 {
     if (exceptionType != null)
         testFixture.Failed("Expected exception of type " + exceptionType.ToString());
 }
        private IEnumerable<MethodInfo> GetTestMethods(TestFixture testFixture)
        {
            Type t = testFixture.GetType();
            List<MethodInfo> _testMethods = new List<MethodInfo>();

            foreach (MethodInfo methodInfo in t.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
            {
                object[] testMethodAttributes =
                    methodInfo.GetCustomAttributes(typeof(TestMethodAttribute), true);

                if (testMethodAttributes.Count() > 0)
                {
                    _testMethods.Add(methodInfo);
                }
            }

            return _testMethods;
        }
        private bool DidFixturePass(TestFixture testFixture)
        {
            if (testFixture.TestResults.FailedTests.Count > 0)
                return false;

            return true;
        }
 private void CallTestTeardown(TestFixture testFixture)
 {
     try
     {
         testFixture.TearDown();
     }
     catch (Exception exception)
     {
         SetFixtureToFailed("TearDown", testFixture, exception);
     }
 }
 private void CallTestSetup(TestFixture testFixture, MethodInfo methodInfo)
 {
     try
     {
         testFixture.Setup();
     }
     catch (Exception exception)
     {
         testFixture.SetClassName(testFixture.GetType().Name);
         testFixture.SetMethodName(methodInfo.Name);
         SetFixtureToFailed("Setup", testFixture, exception);
     }
 }
 private void CallTestMethod(TestFixture testFixture, MethodInfo methodInfo)
 {
     testFixture.SetClassName(testFixture.GetType().Name);
     testFixture.SetMethodName(methodInfo.Name);
     methodInfo.Invoke(testFixture, null);
 }
 private void CallTestFixtureContext(TestFixture testFixture)
 {
     try
     {
         testFixture.Context();
     }
     catch (Exception exception)
     {
         SetFixtureToFailed("Context", testFixture, exception);
     }
 }