
Untitled
By: a guest on Jan 28th, 2012 | syntax:
None | size: 0.82 KB | hits: 7 | expires: Never
namespace Microsoft.VisualStudio.TestTools.UnitTesting
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public static class AssertEx
{
/// <summary>
/// Verifies that the specified exception type is thrown.
/// </summary>
/// <typeparam name="TException">The type of the expected exception.</typeparam>
/// <param name="action">The action.</param>
public static void Throws<TException>(Action action) where TException: Exception
{
try
{
action();
Assert.Fail("No expected '{0}' exception thrown.", typeof(TException));
}
catch (TException)
{
// expected exception
}
}
}
}