Exemplo n.º 1
0
 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));
     }
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 private void FailTestOnExpectedExceptionNotThrown(TestFixture testFixture, Type exceptionType)
 {
     if (exceptionType != null)
         testFixture.Failed("Expected exception of type " + exceptionType.ToString());
 }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        private bool DidFixturePass(TestFixture testFixture)
        {
            if (testFixture.TestResults.FailedTests.Count > 0)
                return false;

            return true;
        }
Exemplo n.º 6
0
 private void CallTestTeardown(TestFixture testFixture)
 {
     try
     {
         testFixture.TearDown();
     }
     catch (Exception exception)
     {
         SetFixtureToFailed("TearDown", testFixture, exception);
     }
 }
Exemplo n.º 7
0
 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);
     }
 }
Exemplo n.º 8
0
 private void CallTestMethod(TestFixture testFixture, MethodInfo methodInfo)
 {
     testFixture.SetClassName(testFixture.GetType().Name);
     testFixture.SetMethodName(methodInfo.Name);
     methodInfo.Invoke(testFixture, null);
 }
Exemplo n.º 9
0
 private void CallTestFixtureContext(TestFixture testFixture)
 {
     try
     {
         testFixture.Context();
     }
     catch (Exception exception)
     {
         SetFixtureToFailed("Context", testFixture, exception);
     }
 }