← Back to team overview

nunit-core team mailing list archive

[Merge] lp:~charlie.poole/nunit-3.0/nunit-2.5-bugs into lp:nunit-3.0

 

Charlie Poole has proposed merging lp:~charlie.poole/nunit-3.0/nunit-2.5-bugs into lp:nunit-3.0.

Requested reviews:
    NUnit Developers (nunit-dev)

Merge in bugfixes and minor feature changes between NUnit 2.5.1 and 2.5.2
-- 
https://code.launchpad.net/~charlie.poole/nunit-3.0/nunit-2.5-bugs/+merge/10574
Your team NUnit Developers is subscribed to branch lp:nunit-3.0.
=== modified file 'solutions/vs2005/framework/nunit.framework.csproj'
--- solutions/vs2005/framework/nunit.framework.csproj	2009-07-16 19:37:36 +0000
+++ solutions/vs2005/framework/nunit.framework.csproj	2009-08-23 04:14:27 +0000
@@ -61,9 +61,6 @@
     <Compile Include="..\..\..\src\framework\Assume.cs">
       <Link>Assume.cs</Link>
     </Compile>
-    <Compile Include="..\..\..\src\framework\Catch.cs">
-      <Link>Catch.cs</Link>
-    </Compile>
     <Compile Include="..\..\..\src\framework\CategoryAttribute.cs">
       <Link>CategoryAttribute.cs</Link>
     </Compile>
@@ -262,6 +259,9 @@
     <Compile Include="..\..\..\src\framework\SetCultureAttribute.cs">
       <Link>SetCultureAttribute.cs</Link>
     </Compile>
+    <Compile Include="..\..\..\src\framework\SetUICultureAttribute.cs">
+      <Link>SetUICultureAttribute.cs</Link>
+    </Compile>
     <Compile Include="..\..\..\src\framework\SetUpAttribute.cs">
       <Link>SetUpAttribute.cs</Link>
     </Compile>

=== modified file 'solutions/vs2008/framework/nunit.framework.csproj'
--- solutions/vs2008/framework/nunit.framework.csproj	2009-07-16 19:37:36 +0000
+++ solutions/vs2008/framework/nunit.framework.csproj	2009-08-23 04:14:27 +0000
@@ -69,9 +69,6 @@
     <Compile Include="..\..\..\src\framework\Assume.cs">
       <Link>Assume.cs</Link>
     </Compile>
-    <Compile Include="..\..\..\src\framework\Catch.cs">
-      <Link>Catch.cs</Link>
-    </Compile>
     <Compile Include="..\..\..\src\framework\CategoryAttribute.cs">
       <Link>CategoryAttribute.cs</Link>
     </Compile>
@@ -270,6 +267,9 @@
     <Compile Include="..\..\..\src\framework\SetCultureAttribute.cs">
       <Link>SetCultureAttribute.cs</Link>
     </Compile>
+    <Compile Include="..\..\..\src\framework\SetUICultureAttribute.cs">
+      <Link>SetUICultureAttribute.cs</Link>
+    </Compile>
     <Compile Include="..\..\..\src\framework\SetUpAttribute.cs">
       <Link>SetUpAttribute.cs</Link>
     </Compile>

=== modified file 'src/framework/Assert.cs'
--- src/framework/Assert.cs	2009-08-21 19:46:23 +0000
+++ src/framework/Assert.cs	2009-08-23 04:14:27 +0000
@@ -524,7 +524,7 @@
         }
         #endregion
 
-        #region Throws and DoesNotThrow
+        #region Throws, Catch and DoesNotThrow
 
         #region Throws
         /// <summary>
@@ -536,7 +536,17 @@
         /// <param name="args">Arguments to be used in formatting the message</param>
         public static Exception Throws(IResolveConstraint expression, TestDelegate code, string message, params object[] args)
         {
-            Exception caughtException = Catch.Exception(code);
+            Exception caughtException = null;
+
+            try
+            {
+                code();
+            }
+            catch (Exception ex)
+            {
+                caughtException = ex;
+            }
+
             Assert.That(caughtException, expression, message, args);
 
             return caughtException;
@@ -635,6 +645,117 @@
 #endif
         #endregion
 
+        #region Catch
+        /// <summary>
+        /// Verifies that a delegate throws an exception when called
+        /// and returns it.
+        /// </summary>
+        /// <param name="code">A TestDelegate</param>
+        /// <param name="message">The message that will be displayed on failure</param>
+        /// <param name="args">Arguments to be used in formatting the message</param>
+        public static Exception Catch(TestDelegate code, string message, params object[] args)
+        {
+            return Throws(new InstanceOfTypeConstraint(typeof(Exception)), code, message, args);
+        }
+
+        /// <summary>
+        /// Verifies that a delegate throws an exception when called
+        /// and returns it.
+        /// </summary>
+        /// <param name="code">A TestDelegate</param>
+        /// <param name="message">The message that will be displayed on failure</param>
+        public static Exception Catch(TestDelegate code, string message)
+        {
+            return Throws(new InstanceOfTypeConstraint(typeof(Exception)), code, message);
+        }
+
+        /// <summary>
+        /// Verifies that a delegate throws an exception when called
+        /// and returns it.
+        /// </summary>
+        /// <param name="code">A TestDelegate</param>
+        public static Exception Catch(TestDelegate code)
+        {
+            return Throws(new InstanceOfTypeConstraint(typeof(Exception)), code);
+        }
+
+        /// <summary>
+        /// Verifies that a delegate throws an exception of a certain Type
+        /// or one derived from it when called and returns it.
+        /// </summary>
+        /// <param name="expectedExceptionType">The expected Exception Type</param>
+        /// <param name="code">A TestDelegate</param>
+        /// <param name="message">The message that will be displayed on failure</param>
+        /// <param name="args">Arguments to be used in formatting the message</param>
+        public static Exception Catch(Type expectedExceptionType, TestDelegate code, string message, params object[] args)
+        {
+            return Throws(new InstanceOfTypeConstraint(expectedExceptionType), code, message, args);
+        }
+
+        /// <summary>
+        /// Verifies that a delegate throws an exception of a certain Type
+        /// or one derived from it when called and returns it.
+        /// </summary>
+        /// <param name="expectedExceptionType">The expected Exception Type</param>
+        /// <param name="code">A TestDelegate</param>
+        /// <param name="message">The message that will be displayed on failure</param>
+        public static Exception Catch(Type expectedExceptionType, TestDelegate code, string message)
+        {
+            return Throws(new InstanceOfTypeConstraint(expectedExceptionType), code, message);
+        }
+
+        /// <summary>
+        /// Verifies that a delegate throws an exception of a certain Type
+        /// or one derived from it when called and returns it.
+        /// </summary>
+        /// <param name="expectedExceptionType">The expected Exception Type</param>
+        /// <param name="code">A TestDelegate</param>
+        public static Exception Catch(Type expectedExceptionType, TestDelegate code)
+        {
+            return Throws(new InstanceOfTypeConstraint(expectedExceptionType), code);
+        }
+        #endregion
+
+        #region Catch<T>
+#if NET_2_0
+        /// <summary>
+        /// Verifies that a delegate throws an exception of a certain Type
+        /// or one derived from it when called and returns it.
+        /// </summary>
+        /// <param name="expectedExceptionType">The expected Exception Type</param>
+        /// <param name="code">A TestDelegate</param>
+        /// <param name="message">The message that will be displayed on failure</param>
+        /// <param name="args">Arguments to be used in formatting the message</param>
+        public static Exception Catch<T>(TestDelegate code, string message, params object[] args)
+        {
+            return Throws(new InstanceOfTypeConstraint(typeof(T)), code, message, args);
+        }
+
+        /// <summary>
+        /// Verifies that a delegate throws an exception of a certain Type
+        /// or one derived from it when called and returns it.
+        /// </summary>
+        /// <param name="expectedExceptionType">The expected Exception Type</param>
+        /// <param name="code">A TestDelegate</param>
+        /// <param name="message">The message that will be displayed on failure</param>
+        public static Exception Catch<T>(TestDelegate code, string message)
+        {
+            return Throws(new InstanceOfTypeConstraint(typeof(T)), code, message);
+        }
+
+        /// <summary>
+        /// Verifies that a delegate throws an exception of a certain Type
+        /// or one derived from it when called and returns it.
+        /// </summary>
+        /// <param name="expectedExceptionType">The expected Exception Type</param>
+        /// <param name="code">A TestDelegate</param>
+        public static Exception Catch<T>(TestDelegate code)
+        {
+            return Throws(new InstanceOfTypeConstraint(typeof(T)), code);
+        }
+#endif
+        #endregion
+
         #region DoesNotThrow
 
         /// <summary>

=== removed file 'src/framework/Catch.cs'
--- src/framework/Catch.cs	2009-07-16 19:37:36 +0000
+++ src/framework/Catch.cs	1970-01-01 00:00:00 +0000
@@ -1,52 +0,0 @@
-// ***********************************************************************
-// Copyright (c) 2008 Charlie Poole
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-// ***********************************************************************
-
-using System;
-using System.Text;
-
-namespace NUnit.Framework
-{
-    /// <summary>
-    /// The Catch class is used to capture an exception.
-    /// </summary>
-    class Catch
-    {
-        /// <summary>
-        /// Capture any exception that is thrown by the delegate
-        /// </summary>
-        /// <param name="code">A TestDelegate</param>
-        /// <returns>The exception thrown, or null</returns>
-        public static Exception Exception(TestDelegate code)
-        {
-            try
-            {
-                code();
-                return null;
-            }
-            catch (Exception ex)
-            {
-                return ex;
-            }
-        }
-    }
-}

=== modified file 'src/framework/Constraints/ConstraintExpression.cs'
--- src/framework/Constraints/ConstraintExpression.cs	2009-07-16 20:05:38 +0000
+++ src/framework/Constraints/ConstraintExpression.cs	2009-08-23 04:31:22 +0000
@@ -174,6 +174,19 @@
         
         #endregion
         
+        #region InnerException
+        
+        /// <summary>
+        /// Returns a new ConstraintExpression, which will apply the following
+        /// constraint to the InnerException property of the object being tested.
+        /// </summary>
+        public ResolvableConstraintExpression InnerException
+        {
+            get { return Property("InnerException"); }
+        }
+        
+        #endregion
+        
         #region Attribute
         
         /// <summary>

=== modified file 'src/framework/Constraints/ConstraintFactory.cs'
--- src/framework/Constraints/ConstraintFactory.cs	2009-07-16 20:05:38 +0000
+++ src/framework/Constraints/ConstraintFactory.cs	2009-08-23 04:31:22 +0000
@@ -157,6 +157,19 @@
         
         #endregion
         
+        #region InnerException
+        
+        /// <summary>
+        /// Returns a new ConstraintExpression, which will apply the following
+        /// constraint to the InnerException property of the object being tested.
+        /// </summary>
+        public ResolvableConstraintExpression InnerException
+        {
+            get { return Has.InnerException; }
+        }
+        
+        #endregion
+        
         #region Attribute
         
         /// <summary>

=== modified file 'src/framework/Constraints/ThrowsConstraint.cs'
--- src/framework/Constraints/ThrowsConstraint.cs	2009-07-16 20:05:38 +0000
+++ src/framework/Constraints/ThrowsConstraint.cs	2009-08-23 04:14:27 +0000
@@ -65,9 +65,18 @@
                 throw new ArgumentException(
                     string.Format("The actual value must be a TestDelegate but was {0}",actual.GetType().Name), "actual");
 
-            this.caughtException = Catch.Exception(code);
-
-            if (caughtException == null)
+            this.caughtException = null;
+
+            try
+            {
+                code();
+            }
+            catch (Exception ex)
+            {
+                this.caughtException = ex;
+            }
+
+            if (this.caughtException == null)
                 return false;
 
             return baseConstraint == null || baseConstraint.Matches(caughtException);
@@ -150,10 +159,19 @@
 			if (code == null)
 				throw new ArgumentException("The actual value must be a TestDelegate", "actual");
 
-			this.caughtException = Catch.Exception(code);
-
-			return caughtException == null;
-		}
+            this.caughtException = null;
+
+            try
+            {
+                code();
+            }
+            catch (Exception ex)
+            {
+                this.caughtException = ex;
+            }
+
+            return this.caughtException == null;
+        }
 
         /// <summary>
         /// Write the constraint description to a MessageWriter

=== modified file 'src/framework/Has.cs'
--- src/framework/Has.cs	2009-07-16 19:37:36 +0000
+++ src/framework/Has.cs	2009-08-23 04:31:22 +0000
@@ -149,6 +149,19 @@
         
         #endregion
         
+        #region InnerException
+        
+        /// <summary>
+        /// Returns a new ConstraintExpression, which will apply the following
+        /// constraint to the InnerException property of the object being tested.
+        /// </summary>
+        public static ResolvableConstraintExpression InnerException
+        {
+            get { return Property("InnerException"); }
+        }
+        
+        #endregion
+        
         #region Attribute
         
         /// <summary>

=== modified file 'src/framework/ITestCaseData.cs'
--- src/framework/ITestCaseData.cs	2009-07-16 19:37:36 +0000
+++ src/framework/ITestCaseData.cs	2009-08-23 02:46:52 +0000
@@ -68,5 +68,17 @@
         /// Gets the description of the test
         /// </summary>
         string Description { get; }
+
+        /// <summary>
+        /// Gets a value indicating whether this <see cref="ITestCaseData"/> is ignored.
+        /// </summary>
+        /// <value><c>true</c> if ignored; otherwise, <c>false</c>.</value>
+        bool Ignored { get; }
+
+        /// <summary>
+        /// Gets the ignore reason.
+        /// </summary>
+        /// <value>The ignore reason.</value>
+        string IgnoreReason { get; }
     }
 }

=== added file 'src/framework/SetUICultureAttribute.cs'
--- src/framework/SetUICultureAttribute.cs	1970-01-01 00:00:00 +0000
+++ src/framework/SetUICultureAttribute.cs	2009-08-23 02:16:07 +0000
@@ -0,0 +1,23 @@
+// ****************************************************************
+// Copyright 2007, Charlie Poole
+// This is free software licensed under the NUnit license. You may
+// obtain a copy of the license at http://nunit.org
+// ****************************************************************
+
+using System;
+
+namespace NUnit.Framework
+{
+    /// <summary>
+    /// Summary description for SetUICultureAttribute.
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Assembly, AllowMultiple = true)]
+    public class SetUICultureAttribute : PropertyAttribute
+    {
+        /// <summary>
+        /// Construct given the name of a culture
+        /// </summary>
+        /// <param name="culture"></param>
+        public SetUICultureAttribute(string culture) : base("_SETUICULTURE", culture) { }
+    }
+}

=== modified file 'src/framework/SyntaxElements.txt'
--- src/framework/SyntaxElements.txt	2009-07-16 19:37:36 +0000
+++ src/framework/SyntaxElements.txt	2009-08-23 04:31:22 +0000
@@ -161,6 +161,15 @@
 Gen: ConstraintExpression.Message=>Property("Message")
 %
 /// <summary>
+/// Returns a new ConstraintExpression, which will apply the following
+/// constraint to the InnerException property of the object being tested.
+/// </summary>
+Type: ResolvableConstraintExpression
+Gen: Has.InnerException=>Property("InnerException")
+Gen: ConstraintFactory.InnerException=>Has.InnerException
+Gen: ConstraintExpression.InnerException=>Property("InnerException")
+%
+/// <summary>
 /// Returns a new AttributeConstraint checking for the
 /// presence of a particular attribute on an object.
 /// </summary>
@@ -179,6 +188,30 @@
 Gen: Throws.Exception=>new ConstraintExpression().Append(new ThrowsOperator())
 %
 /// <summary>
+/// Creates a constraint specifying an exception with a given InnerException
+/// </summary>
+Type: ResolvableConstraintExpression
+Gen: Throws.InnerException=> Exception.InnerException
+%
+/// <summary>
+/// Creates a constraint specifying an expected TargetInvocationException
+/// </summary>
+Type: ExactTypeConstraint
+Gen: Throws.TargetInvocationException=>TypeOf(typeof(System.Reflection.TargetInvocationException))
+%
+/// <summary>
+/// Creates a constraint specifying an expected TargetInvocationException
+/// </summary>
+Type: ExactTypeConstraint
+Gen: Throws.ArgumentException=>TypeOf(typeof(System.ArgumentException))
+%
+/// <summary>
+/// Creates a constraint specifying an expected TargetInvocationException
+/// </summary>
+Type: ExactTypeConstraint
+Gen: Throws.InvalidOperationException=>TypeOf(typeof(System.InvalidOperationException))
+%
+/// <summary>
 /// Creates a constraint specifying that no exception is thrown
 /// </summary>
 Type: ThrowsNothingConstraint

=== modified file 'src/framework/TestCaseAttribute.cs'
--- src/framework/TestCaseAttribute.cs	2009-07-16 19:37:36 +0000
+++ src/framework/TestCaseAttribute.cs	2009-08-23 02:46:52 +0000
@@ -42,6 +42,8 @@
         private MessageMatch matchType;
         private string description;
         private string testName;
+        private bool isIgnored;
+        private string ignoreReason;
 
         /// <summary>
         /// Construct a TestCaseAttribute with a list of arguments.
@@ -170,5 +172,37 @@
             get { return testName; }
             set { testName = value; }
         }
+
+        /// <summary>
+        /// Gets or sets the ignored status of the test
+        /// </summary>
+        public bool Ignore
+        {
+            get { return isIgnored; }
+            set { isIgnored = value; }
+        }
+
+        /// <summary>
+        /// Gets or sets the ignored status of the test
+        /// </summary>
+        public bool Ignored
+        {
+            get { return isIgnored; }
+            set { isIgnored = value; }
+        }
+
+        /// <summary>
+        /// Gets the ignore reason.
+        /// </summary>
+        /// <value>The ignore reason.</value>
+        public string IgnoreReason
+        {
+            get { return ignoreReason; }
+            set
+            {
+                ignoreReason = value;
+                isIgnored = ignoreReason != null && ignoreReason != string.Empty;
+            }
+        }
     }
 }

=== modified file 'src/framework/TestCaseData.cs'
--- src/framework/TestCaseData.cs	2009-07-16 19:37:36 +0000
+++ src/framework/TestCaseData.cs	2009-08-23 02:46:52 +0000
@@ -80,6 +80,17 @@
         /// to tests without requiring the class to change.
         /// </summary>
         private IDictionary properties;
+
+        /// <summary>
+        /// If true, indicates that the test case is to be ignored
+        /// </summary>
+        bool isIgnored;
+
+        /// <summary>
+        /// The reason for ignoring a test case
+        /// </summary>
+        string ignoreReason;
+
         #endregion
 
         #region Constructors
@@ -89,7 +100,7 @@
         /// <param name="args">The arguments.</param>
         public TestCaseData(params object[] args)
         {
-            if (arguments == null)
+            if (args == null)
                 this.arguments = new object[] { null };
             else
                 this.arguments = args;
@@ -174,6 +185,24 @@
         {
             get { return description; }
         }
+
+        /// <summary>
+        /// Gets a value indicating whether this <see cref="ITestCaseData"/> is ignored.
+        /// </summary>
+        /// <value><c>true</c> if ignored; otherwise, <c>false</c>.</value>
+        public bool Ignored
+        {
+            get { return isIgnored; }
+        }
+
+        /// <summary>
+        /// Gets the ignore reason.
+        /// </summary>
+        /// <value>The ignore reason.</value>
+        public string IgnoreReason
+        {
+            get { return ignoreReason; }
+        }
         #endregion
 
         #region Additional Public Properties
@@ -309,6 +338,28 @@
             this.Properties.Add(propName, propValue);
             return this;
         }
+
+        /// <summary>
+        /// Ignores this TestCase.
+        /// </summary>
+        /// <returns></returns>
+        public TestCaseData Ignore()
+        {
+            isIgnored = true;
+            return this;
+        }
+
+        /// <summary>
+        /// Ignores this TestCase, specifying the reason.
+        /// </summary>
+        /// <param name="reason">The reason.</param>
+        /// <returns></returns>
+        public TestCaseData Ignore(string reason)
+        {
+            isIgnored = true;
+            ignoreReason = reason;
+            return this;
+        }
         #endregion
     }
 }

=== modified file 'src/framework/TestFixtureAttribute.cs'
--- src/framework/TestFixtureAttribute.cs	2009-07-16 19:37:36 +0000
+++ src/framework/TestFixtureAttribute.cs	2009-08-23 02:46:52 +0000
@@ -36,6 +36,9 @@
 		private string description;
 
         private object[] arguments;
+        private bool isIgnored;
+        private string ignoreReason;
+
 #if NET_2_0
         private Type[] typeArgs;
         private bool argsSeparated;
@@ -83,6 +86,30 @@
             }
         }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether this <see cref="TestFixtureAttribute"/> should be ignored.
+        /// </summary>
+        /// <value><c>true</c> if ignore; otherwise, <c>false</c>.</value>
+        public bool Ignore
+        {
+            get { return isIgnored; }
+            set { isIgnored = value; }
+        }
+
+        /// <summary>
+        /// Gets or sets the ignore reason. May set Ignored as a side effect.
+        /// </summary>
+        /// <value>The ignore reason.</value>
+        public string IgnoreReason
+        {
+            get { return ignoreReason; }
+            set
+            {
+                ignoreReason = value;
+                isIgnored = ignoreReason != null && ignoreReason != string.Empty;
+            }
+        }
+
 #if NET_2_0
         /// <summary>
         /// Get or set the type arguments. If not set

=== modified file 'src/framework/ThreadingAttributes.cs'
--- src/framework/ThreadingAttributes.cs	2009-07-16 19:37:36 +0000
+++ src/framework/ThreadingAttributes.cs	2009-08-23 03:52:29 +0000
@@ -27,17 +27,18 @@
 namespace NUnit.Framework
 {
     /// <summary>
-    /// Marks a test with a timeout value in milliseconds. The
-    /// test will be run in a separate thread and cancelled if
-    /// the timeout is exceeded.
+    /// WUsed on a method, marks the test with a timeout value in milliseconds. 
+    /// The test will be run in a separate thread and is cancelled if the timeout 
+    /// is exceeded. Used on a method or assembly, sets the default timeout 
+    /// for all contained test methods.
     /// </summary>
-    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)]
+    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false)]
     public class TimeoutAttribute : PropertyAttribute
     {
         /// <summary>
         /// Construct a TimeoutAttribute given a time in milliseconds
         /// </summary>
-        /// <param name="timeout"></param>
+        /// <param name="timeout">The timeout value in milliseconds</param>
         public TimeoutAttribute(int timeout)
             : base(timeout) { }
     }

=== modified file 'src/framework/Throws.cs'
--- src/framework/Throws.cs	2009-07-16 19:37:36 +0000
+++ src/framework/Throws.cs	2009-08-23 04:31:22 +0000
@@ -53,6 +53,54 @@
         
         #endregion
         
+        #region InnerException
+        
+        /// <summary>
+        /// Creates a constraint specifying an exception with a given InnerException
+        /// </summary>
+        public static ResolvableConstraintExpression InnerException
+        {
+            get { return Exception.InnerException; }
+        }
+        
+        #endregion
+        
+        #region TargetInvocationException
+        
+        /// <summary>
+        /// Creates a constraint specifying an expected TargetInvocationException
+        /// </summary>
+        public static ExactTypeConstraint TargetInvocationException
+        {
+            get { return TypeOf(typeof(System.Reflection.TargetInvocationException)); }
+        }
+        
+        #endregion
+        
+        #region ArgumentException
+        
+        /// <summary>
+        /// Creates a constraint specifying an expected TargetInvocationException
+        /// </summary>
+        public static ExactTypeConstraint ArgumentException
+        {
+            get { return TypeOf(typeof(System.ArgumentException)); }
+        }
+        
+        #endregion
+        
+        #region InvalidOperationException
+        
+        /// <summary>
+        /// Creates a constraint specifying an expected TargetInvocationException
+        /// </summary>
+        public static ExactTypeConstraint InvalidOperationException
+        {
+            get { return TypeOf(typeof(System.InvalidOperationException)); }
+        }
+        
+        #endregion
+        
         #region Nothing
         
         /// <summary>

=== modified file 'src/framework/nunit.framework.build'
--- src/framework/nunit.framework.build	2009-08-21 19:49:56 +0000
+++ src/framework/nunit.framework.build	2009-08-23 04:14:27 +0000
@@ -45,7 +45,6 @@
         <include name="AssertionHelper.cs"/>
         <include name="Assume.cs"/>
         <include name="CategoryAttribute.cs"/>
-        <include name="Catch.cs"/>
         <include name="CollectionAssert.cs"/>
         <include name="DatapointAttributes.cs"/>
         <include name="DescriptionAttribute.cs"/>
@@ -74,6 +73,7 @@
     <include name="RepeatAttribute.cs"/>
     <include name="RequiredAddinAttribute.cs"/>
         <include name="SetCultureAttribute.cs"/>
+        <include name="SetUICultureAttribute.cs"/>
         <include name="SetUpAttribute.cs"/>
         <include name="SetUpFixtureAttribute.cs"/>
         <include name="SpecialValue.cs"/>

=== modified file 'tools/src/GenSyntax/Templates/Assert.template.cs'
--- tools/src/GenSyntax/Templates/Assert.template.cs	2009-08-21 19:46:23 +0000
+++ tools/src/GenSyntax/Templates/Assert.template.cs	2009-08-23 04:14:27 +0000
@@ -524,7 +524,7 @@
         }
         #endregion
 
-        #region Throws and DoesNotThrow
+        #region Throws, Catch and DoesNotThrow
 
         #region Throws
         /// <summary>
@@ -536,7 +536,17 @@
         /// <param name="args">Arguments to be used in formatting the message</param>
         public static Exception Throws(IResolveConstraint expression, TestDelegate code, string message, params object[] args)
         {
-            Exception caughtException = Catch.Exception(code);
+            Exception caughtException = null;
+
+            try
+            {
+                code();
+            }
+            catch (Exception ex)
+            {
+                caughtException = ex;
+            }
+
             Assert.That(caughtException, expression, message, args);
 
             return caughtException;
@@ -635,6 +645,117 @@
 #endif
         #endregion
 
+        #region Catch
+        /// <summary>
+        /// Verifies that a delegate throws an exception when called
+        /// and returns it.
+        /// </summary>
+        /// <param name="code">A TestDelegate</param>
+        /// <param name="message">The message that will be displayed on failure</param>
+        /// <param name="args">Arguments to be used in formatting the message</param>
+        public static Exception Catch(TestDelegate code, string message, params object[] args)
+        {
+            return Throws(new InstanceOfTypeConstraint(typeof(Exception)), code, message, args);
+        }
+
+        /// <summary>
+        /// Verifies that a delegate throws an exception when called
+        /// and returns it.
+        /// </summary>
+        /// <param name="code">A TestDelegate</param>
+        /// <param name="message">The message that will be displayed on failure</param>
+        public static Exception Catch(TestDelegate code, string message)
+        {
+            return Throws(new InstanceOfTypeConstraint(typeof(Exception)), code, message);
+        }
+
+        /// <summary>
+        /// Verifies that a delegate throws an exception when called
+        /// and returns it.
+        /// </summary>
+        /// <param name="code">A TestDelegate</param>
+        public static Exception Catch(TestDelegate code)
+        {
+            return Throws(new InstanceOfTypeConstraint(typeof(Exception)), code);
+        }
+
+        /// <summary>
+        /// Verifies that a delegate throws an exception of a certain Type
+        /// or one derived from it when called and returns it.
+        /// </summary>
+        /// <param name="expectedExceptionType">The expected Exception Type</param>
+        /// <param name="code">A TestDelegate</param>
+        /// <param name="message">The message that will be displayed on failure</param>
+        /// <param name="args">Arguments to be used in formatting the message</param>
+        public static Exception Catch(Type expectedExceptionType, TestDelegate code, string message, params object[] args)
+        {
+            return Throws(new InstanceOfTypeConstraint(expectedExceptionType), code, message, args);
+        }
+
+        /// <summary>
+        /// Verifies that a delegate throws an exception of a certain Type
+        /// or one derived from it when called and returns it.
+        /// </summary>
+        /// <param name="expectedExceptionType">The expected Exception Type</param>
+        /// <param name="code">A TestDelegate</param>
+        /// <param name="message">The message that will be displayed on failure</param>
+        public static Exception Catch(Type expectedExceptionType, TestDelegate code, string message)
+        {
+            return Throws(new InstanceOfTypeConstraint(expectedExceptionType), code, message);
+        }
+
+        /// <summary>
+        /// Verifies that a delegate throws an exception of a certain Type
+        /// or one derived from it when called and returns it.
+        /// </summary>
+        /// <param name="expectedExceptionType">The expected Exception Type</param>
+        /// <param name="code">A TestDelegate</param>
+        public static Exception Catch(Type expectedExceptionType, TestDelegate code)
+        {
+            return Throws(new InstanceOfTypeConstraint(expectedExceptionType), code);
+        }
+        #endregion
+
+        #region Catch<T>
+#if NET_2_0
+        /// <summary>
+        /// Verifies that a delegate throws an exception of a certain Type
+        /// or one derived from it when called and returns it.
+        /// </summary>
+        /// <param name="expectedExceptionType">The expected Exception Type</param>
+        /// <param name="code">A TestDelegate</param>
+        /// <param name="message">The message that will be displayed on failure</param>
+        /// <param name="args">Arguments to be used in formatting the message</param>
+        public static Exception Catch<T>(TestDelegate code, string message, params object[] args)
+        {
+            return Throws(new InstanceOfTypeConstraint(typeof(T)), code, message, args);
+        }
+
+        /// <summary>
+        /// Verifies that a delegate throws an exception of a certain Type
+        /// or one derived from it when called and returns it.
+        /// </summary>
+        /// <param name="expectedExceptionType">The expected Exception Type</param>
+        /// <param name="code">A TestDelegate</param>
+        /// <param name="message">The message that will be displayed on failure</param>
+        public static Exception Catch<T>(TestDelegate code, string message)
+        {
+            return Throws(new InstanceOfTypeConstraint(typeof(T)), code, message);
+        }
+
+        /// <summary>
+        /// Verifies that a delegate throws an exception of a certain Type
+        /// or one derived from it when called and returns it.
+        /// </summary>
+        /// <param name="expectedExceptionType">The expected Exception Type</param>
+        /// <param name="code">A TestDelegate</param>
+        public static Exception Catch<T>(TestDelegate code)
+        {
+            return Throws(new InstanceOfTypeConstraint(typeof(T)), code);
+        }
+#endif
+        #endregion
+
         #region DoesNotThrow
 
         /// <summary>


Follow ups