Exemple #1
0
        public void Run(TestFixture fixture, TestReporter reporter)
        {
            var    exception             = Reflection.GetAttribute(methodInfo, typeof(NUnit.Framework.ExpectedExceptionAttribute), false);
            string expectedExceptionName = null;

            if (exception != null)
            {
                expectedExceptionName = (string)Reflection.GetProperty(exception, "ExpectedExceptionName");
                if (expectedExceptionName == null)
                {
                    expectedExceptionName = "";
                }
            }

            int repeatCount     = 1;
            var repeatAttribute = Reflection.GetAttribute(methodInfo, typeof(NUnit.Framework.RepeatAttribute), false);
            var propertiesValue = Reflection.GetProperty(repeatAttribute, "Properties");

            if (propertiesValue != null)
            {
                var properties = (System.Collections.IDictionary)propertiesValue;
                repeatCount = (int)properties["Repeat"];
            }

            try
            {
                for (int i = 0; i < repeatCount; ++i)
                {
                    fixture.Invoke(methodInfo);
                }
            }
            catch (System.Exception e)
            {
                if (Exception.IsSuccessException(e))
                {
                    reporter.Pass((string)Reflection.GetProperty(Exception.InnerException(e), "Message"));
                }
                else
                {
                    Exception.Handle(e, expectedExceptionName);
                    return;
                }
            }

            if (expectedExceptionName != null)
            {
                throw new NUnit.Framework.NoExpectedException("expected " + expectedExceptionName);
            }
        }
Exemple #2
0
 public void Run(TestFixture fixture, TestReporter reporter)
 {
     try
     {
         fixture.Invoke(methodInfo, arguments);
     }
     catch (System.Exception e)
     {
         if (Exception.IsSuccessException(e))
         {
             reporter.Pass((string)Reflection.GetProperty(Exception.InnerException(e), "Message"));
         }
         else
         {
             throw;
         }
     }
 }