5
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6
<script language="JavaScript" type="text/JavaScript"> <!--
8
if (navigator.appName == "Netscape") {
9
if (parseInt(navigator.appVersion) >= 5) {
10
document.writeln("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/styleGuide.css\">");
11
navLine = "<td height=\"1\" bgcolor=\"666030\" width=\"*\"><img src=\"img/blankPixel.gif\"></td>";
13
navLine = "<td height=\"1\" bgcolor=\"666030\" width=\"52%\"><img src=\"img/blankPixel.gif\"></td>";
14
document.writeln("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/styleGuideNN.css\">");
15
document.writeln("<style type=\"text/css\">");
16
document.writeln("<!-- .bodytext { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: .65em; color: #000000 }");
17
document.writeln("-->");
18
document.writeln("</style>");
21
else if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
22
navLine = "<td height=\"1\" bgcolor=\"666030\" width=\"*\"><img src=\"img/blankPixel.gif\"></td>";
23
document.writeln("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/styleGuideIE.css\">");
26
navLine = "<td height=\"1\" bgcolor=\"666030\" width=\"*\"><img src=\"img/blankPixel.gif\"></td>";
27
document.writeln("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/styleGuide.css\">");
33
<body text="#000000" marginwidth="0" rightmargin="0">
35
<table width="100%" border="0" cellspacing="0" cellpadding="0">
37
<td width="25%"><a href="index.html" target="_self">
38
<img src="img/logo.gif" hspace="15" vspace="0" border="0" alt="NUnit"></a></td>
39
<td valign="top"><span class="navTable">
40
<table width="110%" border="0" cellspacing="0" cellpadding="1" height="40" vspace="15" class="divider">
43
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="link">
45
<td bgcolor="#FFFFFF">
46
<table border="0" cellspacing="10" cellpadding="0">
49
<table width="100%" border="0" cellspacing="0" cellpadding="1" class="divider">
52
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="link">
54
<td class="navtext" bgcolor="#FFFFFF">
56
<a href="index.html" target="_self">
57
<img src="img/homeOff.gif" width="40" height="12" alt="Home" border="0"></a></div>
66
<table width="100%" border="0" cellspacing="0" cellpadding="1" class="divider">
69
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="link">
71
<td class="navtext" bgcolor="#FFFFFF">
73
<a href="download.html" target="_self">
74
<img src="img/downloadOff.gif" width="78" height="12" alt="Download" border="0"></a></div>
83
<table width="100%" border="0" cellspacing="0" cellpadding="1" class="divider">
86
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="selected">
90
<a target="_self" href="documentation.html">
91
<img src="img/documentationOn.gif" width="118" height="12" alt="Documentation" border="0"></a></div>
100
<table width="100%" border="0" cellspacing="0" cellpadding="1" class="divider">
103
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="link">
105
<td class="navtext" bgcolor="#FFFFFF">
107
<a href="community.html" target="_self">
108
<img src="img/communityOff.gif" width="83" height="12" alt="Community" border="0"></a></div>
117
<table width="100%" border="0" cellspacing="0" cellpadding="1" class="divider">
120
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="link">
122
<td class="navtext" bgcolor="#FFFFFF">
124
<a href="resources.html" target="_self">
125
<img src="img/resourcesOff.gif" width="81" height="12" alt="Resources" border="0"></a></div>
134
<table width="100%" border="0" cellspacing="0" cellpadding="1" class="divider">
137
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="link">
139
<td class="navtext" bgcolor="#FFFFFF">
141
<a href="contactUs.html" target="_self">
142
<img src="img/contactUsOff.gif" width="83" height="12" alt="Contact Us" border="0"></a></div>
159
<table border="0" cellspacing="0" cellpadding="0" width="100%">
161
<td align="right" width="240">
162
<img src="img/navDiv.gif" width="1" height="23" alt="|"></td>
164
<td width="120"> </td>
167
<td height="1" align="right" valign="top" width="240">
168
<img src="img/cornerPixel.gif" width="1" height="1" alt="*"></td>
169
<script language="JavaScript" type="text/JavaScript"> <!--
170
document.writeln(navLine);
173
<td height="1" align="left" valign="bottom" width="120">
174
<img src="img/cornerPixel.gif" width="1" height="1" alt="*"></td>
177
<td width="240"> </td>
179
<td align="left" width="120">
180
<img src="img/navDiv.gif" width="1" height="23" alt="|"></td>
186
<table width="100%" border="0" cellspacing="0" cellpadding="0">
188
<td valign="top"><br>
189
<table width="90%" border="0" cellspacing="0" cellpadding="0" class="lefttables">
191
<td class="bodytext">
193
<p><b>Expected Exception (NUnit 2.0)</b><br>
194
This is the way to specify that the execution of a test will throw
195
an exception. This attribute takes a parameter which is a Type.
196
The runner will execute the test and if it throws the specific exception,
197
then the test passes. If it throws a different exception the test
198
will fail. This is true even if the thrown exception inherits from
199
the expected exception.<br>
201
ExpectedException Example:</p>
203
<script language="JavaScript">
204
function doClick(index, numTabs, id) {
205
document.all("tab" + id, index).className = "tab";
206
for (var i=1; i < numTabs; i++) {
207
document.all("tab" + id, (index + i) % numTabs).className = "backtab";
209
document.all("code" + id, index).style.display = "";
210
for (var j=1; j < numTabs; j++) {
211
document.all("code" + id, (index + j) % numTabs).style.display = "none";
217
border-left:1px solid cccccc; border-bottom:1px solid cccccc; border-top:1px solid cccccc; border-right:1px solid cccccc; background-color:eeffff; padding-left:10; padding-right:10; padding-top:0; padding-bottom:0
221
border-left:1px solid black; border-top:1px solid black; border-bottom:1px solid black; text-align:center;
224
border-right:0px none black;
225
background-color:eeeeee;
226
cursor:hand; font-style:normal; font-variant:normal; font-weight:normal; font-size:8pt; font-family:verdana
230
border-left:1px solid black; border-top:1px solid black; border-bottom:1px solid black; text-align:center;
233
border-right:0px none black;
234
background-color:cccccc;
235
cursor:hand; font-style:normal; font-variant:normal; font-weight:normal; font-size:8pt; font-family:verdana
239
border-left:1px none cccccc; border-top:0px none cccccc; width:55%;
241
border-bottom:1px none cccccc;
242
border-right:1px none cccccc;
243
background-color:white; font-style:normal; font-variant:normal; font-weight:normal; font-size:8pt; font-family:verdana
247
border-left:1px solid black; border-top:0px none cccccc; width:55%;
249
border-bottom:1px none cccccc;
250
border-right:1px none cccccc;
251
background-color:white; font-style:normal; font-variant:normal; font-weight:normal; font-size:8pt; font-family:verdana
255
<table cellpadding="0" cellspacing="0" width="95%">
257
<td class="code" colspan="4">
258
<pre id="code_ctl2" style="display:">namespace NUnit.Tests
261
using NUnit.Framework;
264
public class SuccessTests
267
[ExpectedException(typeof(InvalidOperationException))]
268
public void ExpectAnException()
273
<pre id="code_ctl2" style="display:none">Imports System
274
Imports Nunit.Framework
276
Namespace Nunit.Tests
278
<TestFixture()> Public Class SuccessTests
279
<Test(), ExpectedException(GetType(Exception))>
280
Public Sub ExpectAnException()
286
<pre id="code_ctl2" style="display:none">#using <Nunit.Framework.dll>
287
using namespace System;
288
using namespace NUnit::Framework;
293
public __gc class SuccessTests
295
[Test] [ExpectedException(__typeof(InvalidOperationException))]
296
void ExpectAnException();
300
#include "cppsample.h"
302
namespace NUnitTests {
307
<td class="topspace"></td>
314
<td class="tab" id="tab_ctl2" onclick="doClick(0, 3, '_ctl2')">
316
<td class="backtab" id="tab_ctl2" onclick="doClick(1, 3, '_ctl2')">
318
<td class="backtab" id="tab_ctl2" onclick="doClick(2, 3, '_ctl2')">
319
<b>Managed C++</b> </td>
320
<td class="space"> </td>
326
<table width="90%" border="0" cellspacing="0" cellpadding="0" class="lefttables">
328
<td class="copyrighttext"><br><hr>
329
Copyright � 2002-2004 James W. Newkirk, Alexei A. Vorontsov. All
330
Rights Reserved. </td>
334
<td width="1" valign="top">
335
<img src="img/sideDivider.gif" width="1" height="435" alt="|"></td>
336
<td width="235" valign="top">
337
<table border="0" cellspacing="0" cellpadding="0" align="center" class="subnavtable">
339
<td align="center" width="15" class="blanktd"><a href="download.html" target="_self"><img src="img/bulletOff.gif" width="8" height="8" alt="*" border="0"></a></td>
340
<td height="25" class="blanktd"><a href="getStarted.html" target="_self"><img src="img/getStarted.gif" width="125" height="12" alt="Getting Started" border="0"></a></td>
343
<td align="center" width="15" class="blanktd"><a href="installation.html" target="_self"><img src="img/bulletOff.gif" width="8" height="8" alt="*" border="0"></a></td>
344
<td height="25" class="blanktd"><a href="installation.html" target="_self"><img src="img/installation.gif" width="99" height="12" alt="Installation" border="0"></a></td>
347
<td align="center" width="15" class="blanktd"><img src="img/bulletOff.gif" width="8" height="8" alt="&#149;" border="0"></td>
348
<td height="25" class="blanktd"><a href="assertions.html" target="_self"><img src="img/assertions.gif" width="83" height="12" alt="Assertions" border="0"></a></td>
351
<td align="center" width="15" class="blanktd"><img src="img/bulletOff.gif" width="8" height="8" alt="&#149;" border="0"></td>
352
<td height="25" class="blanktd"><a href="attributes.html" target="_self"><img src="img/attribute.gif" width="83" height="12" alt="Attributes" border="0"></a></td>
355
<td align="center" width="15" class="blanktd"> </td>
356
<td height="25" class="blanktd"><a href="testFixture.html">
357
<img src="img/testFixtureOff.gif" width="112" height="12" alt="Test Fixture" border="0"></a></td>
360
<td align="center" width="15" class="blanktd"> </td>
361
<td height="25" class="blanktd">
362
<a href="test.html" target="_self">
363
<img src="img/testOff.gif" width="52" height="12" alt="Test" border="0"></a></td>
366
<td align="center" width="15" class="blanktd"> </td>
367
<td height="25" class="blanktd">
368
<a href="setupTeardown.html" target="_self">
369
<img src="img/setupTeardownOff.gif" width="140" height="12" alt="Setup/Teardown" border="0"></a></td>
372
<td align="center" width="15" class="blanktd"> </td>
373
<td height="25" class="blanktd">
374
<a href="exception.html" target="_self">
375
<img src="img/expectedExceptionOn.gif" width="168" height="12" alt="Expected Exception" border="0"></a></td>
378
<td align="center" width="15" class="blanktd"> </td>
379
<td height="25" class="blanktd"><a href="category.html" target="_self"><img src="img/categoryOff.gif" width="92" height="12" alt="Category" border="0"></a></td>
382
<td align="center" width="15" class="blanktd"> </td>
383
<td height="25" class="blanktd"><a href="explicit.html" target="_self"><img src="img/explicitOff.gif" width="80" height="12" alt="Explicit" border="0"></a></td>
386
<td align="center" width="15" class="blanktd"> </td>
387
<td height="25" class="blanktd">
388
<a href="suite.html" target="_self">
389
<img src="img/suiteOff.gif" width="58" height="12" border="0" alt="Suite"></a></td>
392
<td align="center" width="15" class="blanktd"> </td>
393
<td height="25" class="blanktd">
394
<a href="ignore.html" target="_self">
395
<img src="img/ignoreOff.gif" width="72" height="12" alt="Ignore" border="0"></a></td>
398
<td align="center" width="15" class="blanktd">
399
<a href="upgrade.html" target="_self">
400
<img src="img/bulletOff.gif" width="8" height="8" alt="&#149;" border="0"></a></td>
401
<td height="25" class="blanktd">
402
<a href="upgrade.html" target="_self">
403
<img src="img/upgrade.gif" width="83" height="12" alt="Upgrading" border="0"></a></td>
406
<td align="center" width="15" class="blanktd">
407
<a href="commandLine.html" target="_self">
408
<img src="img/bulletOff.gif" width="8" height="8" alt="&#149;" border="0"></a></td>
409
<td height="25" class="blanktd">
410
<a href="commandLine.html" target="_self">
411
<img src="img/commandLine.gif" width="195" height="12" alt="Command-Line Parameters" border="0"></a></td>
414
<td align="center" width="15" class="blanktd"><a href="samples.html" target="_self"><img src="img/bulletOff.gif" width="8" height="8" alt="*" border="0"></a></td>
415
<td height="25" class="blanktd"><a href="samples.html" target="_self"><img src="img/samples.gif" width="60" height="12" alt="Samples" border="0"></a></td>
418
<td align="center" width="15" class="blanktd">
419
<a href="license.html" target="_self">
420
<img src="img/bulletOff.gif" width="8" height="8" alt="&#149;" border="0"></a></td>
421
<td height="25" class="blanktd">
422
<a href="license.html" target="_self">
423
<img src="img/license.gif" width="62" height="12" alt="License" border="0"></a></td>