Click here to Skip to main content
15,898,035 members
Articles / Web Development / ASP.NET

MbUnit : Generative Unit Test Framework

Rate me:
Please Sign up or sign in to vote.
4.70/5 (38 votes)
15 Apr 20046 min read 222.1K   496   120  
A new highly flexible unit test framework with new fixtures
// created on 30/01/2004 at 18:31

namespace GUnit.Core.Framework
{
	using System;
	using GUnit.Core.Framework;
	using GUnit.Core.Invokers;
	
	/// <summary>
	/// Tags method that should throw an exception.
	/// </summary>
	/// <include file="GUnit.Core.Framework.Doc.xml" path="doc/remarkss/remarks[@name='ExpectedExceptionAttribute']"/>	
	[AttributeUsage(AttributeTargets.Method,AllowMultiple=false,Inherited=true)]	
	public class ExpectedExceptionAttribute : DecoratorPatternAttribute
	{
		Type exceptionType;
		
		public ExpectedExceptionAttribute(Type exceptionType)
		{
			if (exceptionType==null)
				throw new ArgumentNullException("exceptionType");
			this.exceptionType = exceptionType;
		}

		public ExpectedExceptionAttribute(Type exceptionType,string description)
		:base(description)
		{
			if (exceptionType==null)
				throw new ArgumentNullException("exceptionType");
			
			this.exceptionType = exceptionType;
		}
		
		public Type ExceptionType
		{
			get
			{
				return this.exceptionType;
			}
		}
		
		public override IRunInvoker GetInvoker(IRunInvoker invoker)
		{
			return new ExpectedExceptionRunInvoker(invoker, this.ExceptionType);
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Engineer
United States United States
Jonathan de Halleux is Civil Engineer in Applied Mathematics. He finished his PhD in 2004 in the rainy country of Belgium. After 2 years in the Common Language Runtime (i.e. .net), he is now working at Microsoft Research on Pex (http://research.microsoft.com/pex).

Comments and Discussions