nunit 2.4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/docs/addinsDialog.html +74 -0
- data/docs/assertions.html +91 -0
- data/docs/attributes.html +89 -0
- data/docs/category.html +265 -0
- data/docs/classicModel.html +92 -0
- data/docs/codeFuncs.js +77 -0
- data/docs/collectionAssert.html +162 -0
- data/docs/collectionConstraints.html +130 -0
- data/docs/comparisonAsserts.html +271 -0
- data/docs/comparisonConstraints.html +109 -0
- data/docs/compoundConstraints.html +97 -0
- data/docs/conditionAsserts.html +123 -0
- data/docs/conditionConstraints.html +106 -0
- data/docs/configEditor.html +93 -0
- data/docs/configFiles.html +155 -0
- data/docs/consoleCommandLine.html +271 -0
- data/docs/constraintModel.html +134 -0
- data/docs/contextMenu.html +106 -0
- data/docs/culture.html +255 -0
- data/docs/customAsserts.html +115 -0
- data/docs/customConstraints.html +101 -0
- data/docs/description.html +178 -0
- data/docs/equalConstraint.html +139 -0
- data/docs/equalityAsserts.html +187 -0
- data/docs/exception.html +296 -0
- data/docs/explicit.html +256 -0
- data/docs/extensibility.html +83 -0
- data/docs/favicon.ico +0 -0
- data/docs/features.html +75 -0
- data/docs/fileAssert.html +114 -0
- data/docs/files/QuickStart.Spanish.doc +0 -0
- data/docs/files/QuickStart.doc +0 -0
- data/docs/files/Results.xsd +70 -0
- data/docs/files/Summary.xslt +47 -0
- data/docs/files/TestResult.xml +103 -0
- data/docs/files/Thumbs.db +0 -0
- data/docs/fixtureSetup.html +201 -0
- data/docs/fixtureTeardown.html +204 -0
- data/docs/getStarted.html +80 -0
- data/docs/guiCommandLine.html +183 -0
- data/docs/identityAsserts.html +99 -0
- data/docs/ignore.html +249 -0
- data/docs/img/addinsDialog.JPG +0 -0
- data/docs/img/assembliesTab.jpg +0 -0
- data/docs/img/assemblyReloadOptions.JPG +0 -0
- data/docs/img/bulletOff.gif +0 -0
- data/docs/img/bulletOn.gif +0 -0
- data/docs/img/configEditor.jpg +0 -0
- data/docs/img/console-mock.jpg +0 -0
- data/docs/img/displayTab.jpg +0 -0
- data/docs/img/generalOptions.jpg +0 -0
- data/docs/img/generalTab.jpg +0 -0
- data/docs/img/gui-screenshot.jpg +0 -0
- data/docs/img/gui-verify.jpg +0 -0
- data/docs/img/langFilter.gif +0 -0
- data/docs/img/logo.gif +0 -0
- data/docs/img/miniGui.jpg +0 -0
- data/docs/img/optionsDialog.jpg +0 -0
- data/docs/img/resultTab.jpg +0 -0
- data/docs/img/testLoadOptions.jpg +0 -0
- data/docs/img/testOutputOptions.jpg +0 -0
- data/docs/img/testProperties.jpg +0 -0
- data/docs/img/testResultOptions.JPG +0 -0
- data/docs/img/testTab.jpg +0 -0
- data/docs/img/testsTab.JPG +0 -0
- data/docs/img/textOutputOptions.jpg +0 -0
- data/docs/img/treeDisplayOptions.JPG +0 -0
- data/docs/img/visualStudioOptions.JPG +0 -0
- data/docs/index.html +75 -0
- data/docs/installation.html +172 -0
- data/docs/license.html +88 -0
- data/docs/listMapper.html +100 -0
- data/docs/mainMenu.html +260 -0
- data/docs/multiAssembly.html +130 -0
- data/docs/nunit-console.html +84 -0
- data/docs/nunit-gui.html +115 -0
- data/docs/nunit.css +118 -0
- data/docs/nunitAddins.html +331 -0
- data/docs/optionsDialog.html +262 -0
- data/docs/platform.html +285 -0
- data/docs/platformSupport.html +99 -0
- data/docs/projectEditor.html +127 -0
- data/docs/property.html +219 -0
- data/docs/propertyConstraint.html +89 -0
- data/docs/quickStart.html +314 -0
- data/docs/releaseNotes.html +1235 -0
- data/docs/sameasConstraint.html +98 -0
- data/docs/samples.html +126 -0
- data/docs/setCulture.html +173 -0
- data/docs/setup.html +199 -0
- data/docs/setupFixture.html +198 -0
- data/docs/stringAssert.html +107 -0
- data/docs/stringConstraints.html +111 -0
- data/docs/suite.html +222 -0
- data/docs/teardown.html +204 -0
- data/docs/test.html +171 -0
- data/docs/testFixture.html +168 -0
- data/docs/testProperties.html +76 -0
- data/docs/typeAsserts.html +101 -0
- data/docs/typeConstraints.html +103 -0
- data/docs/upgrade.html +97 -0
- data/docs/utilityAsserts.html +108 -0
- data/docs/vsSupport.html +140 -0
- data/lib/net-1.1/Failure.jpg +0 -0
- data/lib/net-1.1/Ignored.jpg +0 -0
- data/lib/net-1.1/NUnitFitTests.html +277 -0
- data/lib/net-1.1/NUnitTests.config +84 -0
- data/lib/net-1.1/NUnitTests.nunit +14 -0
- data/lib/net-1.1/Success.jpg +0 -0
- data/lib/net-1.1/clr.bat +96 -0
- data/lib/net-1.1/fit.dll +0 -0
- data/lib/net-1.1/loadtest-assembly.dll +0 -0
- data/lib/net-1.1/mock-assembly.dll +0 -0
- data/lib/net-1.1/nonamespace-assembly.dll +0 -0
- data/lib/net-1.1/notestfixtures-assembly.dll +0 -0
- data/lib/net-1.1/nunit-console-runner.dll +0 -0
- data/lib/net-1.1/nunit-console.exe +0 -0
- data/lib/net-1.1/nunit-console.exe.config +117 -0
- data/lib/net-1.1/nunit-console.tests.dll +0 -0
- data/lib/net-1.1/nunit-gui-runner.dll +0 -0
- data/lib/net-1.1/nunit-gui.tests.dll +0 -0
- data/lib/net-1.1/nunit.core.dll +0 -0
- data/lib/net-1.1/nunit.core.extensions.dll +0 -0
- data/lib/net-1.1/nunit.core.interfaces.dll +0 -0
- data/lib/net-1.1/nunit.core.tests.dll +0 -0
- data/lib/net-1.1/nunit.exe +0 -0
- data/lib/net-1.1/nunit.exe.config +121 -0
- data/lib/net-1.1/nunit.extensions.tests.dll +0 -0
- data/lib/net-1.1/nunit.fixtures.dll +0 -0
- data/lib/net-1.1/nunit.fixtures.tests.dll +0 -0
- data/lib/net-1.1/nunit.framework.dll +0 -0
- data/lib/net-1.1/nunit.framework.extensions.dll +0 -0
- data/lib/net-1.1/nunit.framework.tests.dll +0 -0
- data/lib/net-1.1/nunit.framework.xml +5622 -0
- data/lib/net-1.1/nunit.mocks.dll +0 -0
- data/lib/net-1.1/nunit.mocks.tests.dll +0 -0
- data/lib/net-1.1/nunit.uikit.dll +0 -0
- data/lib/net-1.1/nunit.uikit.tests.dll +0 -0
- data/lib/net-1.1/nunit.util.dll +0 -0
- data/lib/net-1.1/nunit.util.tests.dll +0 -0
- data/lib/net-1.1/runFile.exe +0 -0
- data/lib/net-1.1/runFile.exe.config +43 -0
- data/lib/net-1.1/test-assembly.dll +0 -0
- data/lib/net-1.1/test-utilities.dll +0 -0
- data/lib/net-1.1/timing-tests.dll +0 -0
- data/lib/net-2.0/Failure.jpg +0 -0
- data/lib/net-2.0/Ignored.jpg +0 -0
- data/lib/net-2.0/NUnitFitTests.html +277 -0
- data/lib/net-2.0/NUnitTests.config +84 -0
- data/lib/net-2.0/NUnitTests.nunit +14 -0
- data/lib/net-2.0/Success.jpg +0 -0
- data/lib/net-2.0/clr.bat +96 -0
- data/lib/net-2.0/fit.dll +0 -0
- data/lib/net-2.0/loadtest-assembly.dll +0 -0
- data/lib/net-2.0/mock-assembly.dll +0 -0
- data/lib/net-2.0/nonamespace-assembly.dll +0 -0
- data/lib/net-2.0/notestfixtures-assembly.dll +0 -0
- data/lib/net-2.0/nunit-console-runner.dll +0 -0
- data/lib/net-2.0/nunit-console-x86.exe +0 -0
- data/lib/net-2.0/nunit-console-x86.exe.config +117 -0
- data/lib/net-2.0/nunit-console.exe +0 -0
- data/lib/net-2.0/nunit-console.exe.config +117 -0
- data/lib/net-2.0/nunit-console.tests.dll +0 -0
- data/lib/net-2.0/nunit-gui-runner.dll +0 -0
- data/lib/net-2.0/nunit-gui.tests.dll +0 -0
- data/lib/net-2.0/nunit-x86.exe +0 -0
- data/lib/net-2.0/nunit-x86.exe.config +121 -0
- data/lib/net-2.0/nunit.core.dll +0 -0
- data/lib/net-2.0/nunit.core.extensions.dll +0 -0
- data/lib/net-2.0/nunit.core.interfaces.dll +0 -0
- data/lib/net-2.0/nunit.core.tests.dll +0 -0
- data/lib/net-2.0/nunit.exe +0 -0
- data/lib/net-2.0/nunit.exe.config +121 -0
- data/lib/net-2.0/nunit.extensions.tests.dll +0 -0
- data/lib/net-2.0/nunit.fixtures.dll +0 -0
- data/lib/net-2.0/nunit.fixtures.tests.dll +0 -0
- data/lib/net-2.0/nunit.framework.dll +0 -0
- data/lib/net-2.0/nunit.framework.extensions.dll +0 -0
- data/lib/net-2.0/nunit.framework.tests.dll +0 -0
- data/lib/net-2.0/nunit.framework.xml +5622 -0
- data/lib/net-2.0/nunit.mocks.dll +0 -0
- data/lib/net-2.0/nunit.mocks.tests.dll +0 -0
- data/lib/net-2.0/nunit.uikit.dll +0 -0
- data/lib/net-2.0/nunit.uikit.tests.dll +0 -0
- data/lib/net-2.0/nunit.util.dll +0 -0
- data/lib/net-2.0/nunit.util.tests.dll +0 -0
- data/lib/net-2.0/runFile.exe +0 -0
- data/lib/net-2.0/runFile.exe.config +43 -0
- data/lib/net-2.0/test-assembly.dll +0 -0
- data/lib/net-2.0/test-utilities.dll +0 -0
- data/lib/net-2.0/timing-tests.dll +0 -0
- metadata +262 -0
data/docs/culture.html
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
|
2
|
+
<html>
|
|
3
|
+
<!-- Standard Head Part -->
|
|
4
|
+
<head>
|
|
5
|
+
<title>NUnit - Culture</title>
|
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
|
7
|
+
<meta http-equiv="Content-Language" content="en-US">
|
|
8
|
+
<link rel="stylesheet" type="text/css" href="nunit.css">
|
|
9
|
+
<link rel="shortcut icon" href="favicon.ico">
|
|
10
|
+
</head>
|
|
11
|
+
<!-- End Standard Head Part -->
|
|
12
|
+
|
|
13
|
+
<body>
|
|
14
|
+
|
|
15
|
+
<!-- Standard Header for NUnit.org -->
|
|
16
|
+
<div id="header">
|
|
17
|
+
<a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a>
|
|
18
|
+
<div id="nav">
|
|
19
|
+
<a href="http://www.nunit.org">NUnit</a>
|
|
20
|
+
<a class="active" href="index.html">Documentation</a>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
<!-- End of Header -->
|
|
24
|
+
|
|
25
|
+
<div id="content">
|
|
26
|
+
|
|
27
|
+
<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE -->
|
|
28
|
+
|
|
29
|
+
<style><!--
|
|
30
|
+
div.code { width: 34em }
|
|
31
|
+
--></style>
|
|
32
|
+
|
|
33
|
+
<h3>CultureAttribute (NUnit 2.4.2)</h3>
|
|
34
|
+
<p>The Culture attribute is used to specify cultures for which a test or fixture
|
|
35
|
+
should be run. It does not affect the culture setting, but merely uses it to
|
|
36
|
+
determine whether to run the test. If you wish to change the culture when
|
|
37
|
+
running a test, use the SetCulture attribute instead.</p>
|
|
38
|
+
|
|
39
|
+
<p>If the specified culture requirements for a test are not met it is skipped.
|
|
40
|
+
In the gui, the tree node for the test remains gray and the status bar color is
|
|
41
|
+
not affected.</p>
|
|
42
|
+
|
|
43
|
+
<p>One use of the Culture attribute is to provide alternative tests under different
|
|
44
|
+
cultures. You may specify either specific cultures, like "en-GB" or neutral
|
|
45
|
+
cultures like "de".</p>
|
|
46
|
+
|
|
47
|
+
<h4>Test Fixture Syntax</h4>
|
|
48
|
+
|
|
49
|
+
<div class="code">
|
|
50
|
+
|
|
51
|
+
<div class="langFilter">
|
|
52
|
+
<a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a>
|
|
53
|
+
<div id="DD1" class="dropdown" style="display: none;" onclick="Hide('DD1')">
|
|
54
|
+
<a href="javascript:ShowCS()">C#</a><br>
|
|
55
|
+
<a href="javascript:ShowVB()">VB</a><br>
|
|
56
|
+
<a href="javascript:ShowMC()">C++</a><br>
|
|
57
|
+
<a href="javascript:ShowJS()">J#</a><br>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<pre class="cs">namespace NUnit.Tests
|
|
62
|
+
{
|
|
63
|
+
using System;
|
|
64
|
+
using NUnit.Framework;
|
|
65
|
+
|
|
66
|
+
[TestFixture]
|
|
67
|
+
[Culture("fr-FR")]
|
|
68
|
+
public class FrenchCultureTests
|
|
69
|
+
{
|
|
70
|
+
// ...
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
</pre>
|
|
74
|
+
|
|
75
|
+
<pre class="vb">Imports System
|
|
76
|
+
Imports Nunit.Framework
|
|
77
|
+
|
|
78
|
+
Namespace Nunit.Tests
|
|
79
|
+
|
|
80
|
+
<TestFixture(), Culture("fr-FR")>
|
|
81
|
+
Public Class FrenchCultureTests
|
|
82
|
+
' ...
|
|
83
|
+
End Class
|
|
84
|
+
End Namespace
|
|
85
|
+
</pre>
|
|
86
|
+
|
|
87
|
+
<pre class="mc">#using <Nunit.Framework.dll>
|
|
88
|
+
using namespace System;
|
|
89
|
+
using namespace NUnit::Framework;
|
|
90
|
+
|
|
91
|
+
namespace NUnitTests
|
|
92
|
+
{
|
|
93
|
+
[TestFixture]
|
|
94
|
+
[Culture("fr-FR")]
|
|
95
|
+
public __gc class FrenchCultureTests
|
|
96
|
+
{
|
|
97
|
+
// ...
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#include "cppsample.h"
|
|
102
|
+
|
|
103
|
+
namespace NUnitTests {
|
|
104
|
+
// ...
|
|
105
|
+
}
|
|
106
|
+
</pre>
|
|
107
|
+
|
|
108
|
+
<pre class="js">package NUnit.Tests;
|
|
109
|
+
|
|
110
|
+
import System.*;
|
|
111
|
+
import NUnit.Framework.TestFixture;
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
/** @attribute NUnit.Framework.TestFixture() */
|
|
115
|
+
/** @attribute NUnit.Framework.Culture("fr-FR") */
|
|
116
|
+
public class FrenchCultureTests
|
|
117
|
+
{
|
|
118
|
+
// ...
|
|
119
|
+
}
|
|
120
|
+
</pre>
|
|
121
|
+
</div>
|
|
122
|
+
<h4>Test Syntax</h4>
|
|
123
|
+
<div class="code">
|
|
124
|
+
|
|
125
|
+
<div class="langFilter">
|
|
126
|
+
<a href="javascript:Show('DD2')" onmouseover="Show('DD2')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a>
|
|
127
|
+
<div id="DD2" class="dropdown" style="display: none;" onclick="Hide('DD2')">
|
|
128
|
+
<a href="javascript:ShowCS()">C#</a><br>
|
|
129
|
+
<a href="javascript:ShowVB()">VB</a><br>
|
|
130
|
+
<a href="javascript:ShowMC()">C++</a><br>
|
|
131
|
+
<a href="javascript:ShowJS()">J#</a><br>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
<pre class="cs">namespace NUnit.Tests
|
|
136
|
+
{
|
|
137
|
+
using System;
|
|
138
|
+
using NUnit.Framework;
|
|
139
|
+
|
|
140
|
+
[TestFixture]
|
|
141
|
+
public class SuccessTests
|
|
142
|
+
{
|
|
143
|
+
[Test]
|
|
144
|
+
[Culture(Exclude="en,de")]
|
|
145
|
+
public void SomeTest()
|
|
146
|
+
{ /* ... */ }
|
|
147
|
+
}
|
|
148
|
+
</pre>
|
|
149
|
+
|
|
150
|
+
<pre class="vb">Imports System
|
|
151
|
+
Imports Nunit.Framework
|
|
152
|
+
|
|
153
|
+
Namespace Nunit.Tests
|
|
154
|
+
|
|
155
|
+
<TestFixture()>
|
|
156
|
+
Public Class SuccessTests
|
|
157
|
+
<Test(), Culture(Exclude="en,de")> Public Sub SomeTest()
|
|
158
|
+
' ...
|
|
159
|
+
End Sub
|
|
160
|
+
End Class
|
|
161
|
+
End Namespace
|
|
162
|
+
</pre>
|
|
163
|
+
|
|
164
|
+
<pre class="mc">#using <Nunit.Framework.dll>
|
|
165
|
+
using namespace System;
|
|
166
|
+
using namespace NUnit::Framework;
|
|
167
|
+
|
|
168
|
+
namespace NUnitTests
|
|
169
|
+
{
|
|
170
|
+
[TestFixture]
|
|
171
|
+
public __gc class SuccessTests
|
|
172
|
+
{
|
|
173
|
+
[Test][Culture(Exclude="en,de")] void SomeTest();
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
#include "cppsample.h"
|
|
178
|
+
|
|
179
|
+
namespace NUnitTests {
|
|
180
|
+
// ...
|
|
181
|
+
}
|
|
182
|
+
</pre>
|
|
183
|
+
|
|
184
|
+
<pre class="js">package NUnit.Tests;
|
|
185
|
+
|
|
186
|
+
import System.*;
|
|
187
|
+
import NUnit.Framework.TestFixture;
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
/** @attribute NUnit.Framework.TestFixture() */
|
|
191
|
+
public class SuccessTests
|
|
192
|
+
{
|
|
193
|
+
/** @attribute NUnit.Framework.Test() */
|
|
194
|
+
/** @attribute NUnit.Framework.Culture(Exclude=en,de") */
|
|
195
|
+
public void SomeTest()
|
|
196
|
+
{ /* ... */ }
|
|
197
|
+
}
|
|
198
|
+
</pre>
|
|
199
|
+
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
<h4>See also...</h4>
|
|
203
|
+
<ul>
|
|
204
|
+
<li><a href="setCulture.html">SetCultureAttribute</a></ul>
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
<!-- Submenu -->
|
|
210
|
+
<div id="subnav">
|
|
211
|
+
<ul>
|
|
212
|
+
<li><a href="index.html">NUnit 2.4.8</a></li>
|
|
213
|
+
<ul>
|
|
214
|
+
<li><a href="getStarted.html">Getting Started</a></li>
|
|
215
|
+
<li><a href="assertions.html">Assertions</a></li>
|
|
216
|
+
<li><a href="attributes.html">Attributes</a></li>
|
|
217
|
+
<ul>
|
|
218
|
+
<li><a href="category.html">Category</a></li>
|
|
219
|
+
<li id="current"><a href="culture.html">Culture</a></li>
|
|
220
|
+
<li><a href="description.html">Description</a></li>
|
|
221
|
+
<li><a href="exception.html">Expected Exception</a></li>
|
|
222
|
+
<li><a href="explicit.html">Explicit</a></li>
|
|
223
|
+
<li><a href="ignore.html">Ignore</a></li>
|
|
224
|
+
<li><a href="platform.html">Platform</a></li>
|
|
225
|
+
<li><a href="property.html">Property</a></li>
|
|
226
|
+
<li><a href="setCulture.html">SetCulture</a></li>
|
|
227
|
+
<li><a href="setup.html">Setup</a></li>
|
|
228
|
+
<li><a href="setupFixture.html">SetUp Fixture</a></li>
|
|
229
|
+
<li><a href="suite.html">Suite</a></li>
|
|
230
|
+
<li><a href="teardown.html">Teardown</a></li>
|
|
231
|
+
<li><a href="test.html">Test</a></li>
|
|
232
|
+
<li><a href="testFixture.html">Test Fixture</a></li>
|
|
233
|
+
<li><a href="fixtureSetup.html">Test Fixture SetUp</a></li>
|
|
234
|
+
<li><a href="fixtureTeardown.html">Test Fixture TearDown</a></li>
|
|
235
|
+
</ul>
|
|
236
|
+
<li><a href="nunit-console.html">Console Runner</a></li>
|
|
237
|
+
<li><a href="nunit-gui.html">Gui Runner</a></li>
|
|
238
|
+
<li><a href="features.html">Other Features</a></li>
|
|
239
|
+
<li><a href="releaseNotes.html">Release Notes</a></li>
|
|
240
|
+
<li><a href="samples.html">Samples</a></li>
|
|
241
|
+
<li><a href="license.html">License</a></li>
|
|
242
|
+
</ul>
|
|
243
|
+
</ul>
|
|
244
|
+
</div>
|
|
245
|
+
<!-- End of Submenu -->
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
<!-- Standard Footer for NUnit.org -->
|
|
249
|
+
<div id="footer">
|
|
250
|
+
Copyright © 2008 Charlie Poole. All Rights Reserved.
|
|
251
|
+
</div>
|
|
252
|
+
<!-- End of Footer -->
|
|
253
|
+
|
|
254
|
+
</body>
|
|
255
|
+
</html>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
|
2
|
+
<html>
|
|
3
|
+
<!-- Standard Head Part -->
|
|
4
|
+
<head>
|
|
5
|
+
<title>NUnit - CustomAsserts</title>
|
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
|
7
|
+
<meta http-equiv="Content-Language" content="en-US">
|
|
8
|
+
<link rel="stylesheet" type="text/css" href="nunit.css">
|
|
9
|
+
<link rel="shortcut icon" href="favicon.ico">
|
|
10
|
+
</head>
|
|
11
|
+
<!-- End Standard Head Part -->
|
|
12
|
+
|
|
13
|
+
<body>
|
|
14
|
+
|
|
15
|
+
<!-- Standard Header for NUnit.org -->
|
|
16
|
+
<div id="header">
|
|
17
|
+
<a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a>
|
|
18
|
+
<div id="nav">
|
|
19
|
+
<a href="http://www.nunit.org">NUnit</a>
|
|
20
|
+
<a class="active" href="index.html">Documentation</a>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
<!-- End of Header -->
|
|
24
|
+
|
|
25
|
+
<div id="content">
|
|
26
|
+
|
|
27
|
+
<h2>Custom Asserts</h2>
|
|
28
|
+
|
|
29
|
+
<div style="text-align: center; margin: 2em 10%; padding: 4px 0; border: 2px solid black">
|
|
30
|
+
<h4>Preliminary documentation, subject to change.</h4>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<p>Experienced developers using NUnit generally end up with a library of custom
|
|
34
|
+
setup, teardown, test and support methods. Custom Asserts provide one way to
|
|
35
|
+
re-package such methods, allowing the normal NUnit syntax to be used to
|
|
36
|
+
invoke them and providing error messages that match the style and layout
|
|
37
|
+
of standard NUnit messages.</p>
|
|
38
|
+
|
|
39
|
+
<p>The standard NUnit Asserts create an object known as an <b>asserter</b> and
|
|
40
|
+
pass it to the <b>DoAssert</b> method, which includes code similar to this...
|
|
41
|
+
|
|
42
|
+
<pre>
|
|
43
|
+
if ( !asserter.Test() )
|
|
44
|
+
throw new AssertionException( asserter.Message );
|
|
45
|
+
</pre></p>
|
|
46
|
+
|
|
47
|
+
<p><b>Asserters</b> encapsulate the comparison to be performed as well as the
|
|
48
|
+
objects being compared. They implement the <b>IAsserter</b> interface,
|
|
49
|
+
defined as follows:
|
|
50
|
+
|
|
51
|
+
<pre>
|
|
52
|
+
public interface IAsserter
|
|
53
|
+
{
|
|
54
|
+
// Test the condition for the assertion.
|
|
55
|
+
bool Test();
|
|
56
|
+
|
|
57
|
+
// Return the message giving the failure reason.
|
|
58
|
+
string Message { get; }
|
|
59
|
+
}
|
|
60
|
+
</pre></p>
|
|
61
|
+
|
|
62
|
+
<p>When implementing an <b>asserter</b>, you will have to decide on an approach
|
|
63
|
+
for creating the message. For complex tests, it may be necessary to create
|
|
64
|
+
and cache the message - or info used to create it - while the test is
|
|
65
|
+
being performed. For example, when NUnit compares arrays, it notes the
|
|
66
|
+
point of failure for use in the message. Otherwise, it would have to
|
|
67
|
+
pass the entire array a second time.</p>
|
|
68
|
+
|
|
69
|
+
<p>Generally, the constructor for the <b>asserter</b> will include any required
|
|
70
|
+
parameters, the actual value and an optional user message. You may invoke
|
|
71
|
+
the asserter directly, using <b>Assert.DoAssert</b>, but it is generally more
|
|
72
|
+
convenient and readable to create an class similar to NUNit's <b>Assert</b> class,
|
|
73
|
+
which contains static methods that wrap the object creation. For an example of
|
|
74
|
+
how to do this, see the <b>StringAssert</b> class in the NUnit source.</p>
|
|
75
|
+
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<!-- Submenu -->
|
|
79
|
+
<div id="subnav">
|
|
80
|
+
<ul>
|
|
81
|
+
<li><a href="index.html">NUnit 2.4.8</a></li>
|
|
82
|
+
<ul>
|
|
83
|
+
<li><a href="getStarted.html">Getting Started</a></li>
|
|
84
|
+
<li><a href="assertions.html">Assertions</a></li>
|
|
85
|
+
<li><a href="attributes.html">Attributes</a></li>
|
|
86
|
+
<li><a href="nunit-console.html">Console Runner</a></li>
|
|
87
|
+
<li><a href="nunit-gui.html">Gui Runner</a></li>
|
|
88
|
+
<li><a href="features.html">Other Features</a></li>
|
|
89
|
+
<ul>
|
|
90
|
+
<li><a href="configFiles.html">Configuration Files</a></li>
|
|
91
|
+
<li><a href="multiAssembly.html">Multiple Assemblies</a></li>
|
|
92
|
+
<li><a href="vsSupport.html">Visual Studio Support</a></li>
|
|
93
|
+
<li><a href="extensibility.html">Extensibility</a></li>
|
|
94
|
+
<ul>
|
|
95
|
+
<li id="current"><a href="customAsserts.html">Custom Asserts</a></li>
|
|
96
|
+
<li><a href="nunitAddins.html">NUnit Addins</a></li>
|
|
97
|
+
</ul>
|
|
98
|
+
</ul>
|
|
99
|
+
<li><a href="releaseNotes.html">Release Notes</a></li>
|
|
100
|
+
<li><a href="samples.html">Samples</a></li>
|
|
101
|
+
<li><a href="license.html">License</a></li>
|
|
102
|
+
</ul>
|
|
103
|
+
</ul>
|
|
104
|
+
</div>
|
|
105
|
+
<!-- End of Submenu -->
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
<!-- Standard Footer for NUnit.org -->
|
|
109
|
+
<div id="footer">
|
|
110
|
+
Copyright © 2008 Charlie Poole. All Rights Reserved.
|
|
111
|
+
</div>
|
|
112
|
+
<!-- End of Footer -->
|
|
113
|
+
|
|
114
|
+
</body>
|
|
115
|
+
</html>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
|
2
|
+
<html>
|
|
3
|
+
<!-- Standard Head Part -->
|
|
4
|
+
<head>
|
|
5
|
+
<title>NUnit - CustomConstraints</title>
|
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
|
7
|
+
<meta http-equiv="Content-Language" content="en-US">
|
|
8
|
+
<link rel="stylesheet" type="text/css" href="nunit.css">
|
|
9
|
+
<link rel="shortcut icon" href="favicon.ico">
|
|
10
|
+
</head>
|
|
11
|
+
<!-- End Standard Head Part -->
|
|
12
|
+
|
|
13
|
+
<body>
|
|
14
|
+
|
|
15
|
+
<!-- Standard Header for NUnit.org -->
|
|
16
|
+
<div id="header">
|
|
17
|
+
<a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a>
|
|
18
|
+
<div id="nav">
|
|
19
|
+
<a href="http://www.nunit.org">NUnit</a>
|
|
20
|
+
<a class="active" href="index.html">Documentation</a>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
<!-- End of Header -->
|
|
24
|
+
|
|
25
|
+
<div id="content">
|
|
26
|
+
|
|
27
|
+
<h2>Custom Constraints (NUnit 2.4)</h2>
|
|
28
|
+
|
|
29
|
+
<p>You can implement your own custom constraints by creating a class that
|
|
30
|
+
inherits from the <b>Constraint</b> abstract class, which supports performing a
|
|
31
|
+
test on an actual value and generating appropriate messages. The class includes
|
|
32
|
+
two abstract methods, which you must override and two virtual methods which
|
|
33
|
+
may be overridden as needed:
|
|
34
|
+
|
|
35
|
+
<div class="code" style="width: 36em">
|
|
36
|
+
<pre>public abstract class Constraint
|
|
37
|
+
{
|
|
38
|
+
...
|
|
39
|
+
public abstract bool Matches( object actual );
|
|
40
|
+
public abstract void WriteDescriptionTo( MessageWriter writer );
|
|
41
|
+
public virtual void WriteMessageTo( MessageWriter writer );
|
|
42
|
+
public virtual void WriteActualValueTo( MessageWriter writer );
|
|
43
|
+
...
|
|
44
|
+
}</pre>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<p>Your derived class should save the actual argument to Matches in the protected
|
|
48
|
+
field actual for later use.
|
|
49
|
+
|
|
50
|
+
<p>The MessageWriter abstract class is implemented in the framework by
|
|
51
|
+
TextMessageWriter. Examining the source for some of the builtin constraints
|
|
52
|
+
should give you a good idea of how to use it.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<!-- Submenu -->
|
|
58
|
+
<div id="subnav">
|
|
59
|
+
<ul>
|
|
60
|
+
<li><a href="index.html">NUnit 2.4.8</a></li>
|
|
61
|
+
<ul>
|
|
62
|
+
<li><a href="getStarted.html">Getting Started</a></li>
|
|
63
|
+
<li><a href="assertions.html">Assertions</a></li>
|
|
64
|
+
<ul>
|
|
65
|
+
<li><a href="classicModel.html">Classic Model</a></li>
|
|
66
|
+
<li><a href="constraintModel.html">Constraint Model</a></li>
|
|
67
|
+
<ul>
|
|
68
|
+
<li><a href="equalConstraint.html">Equal Constraint</a></li>
|
|
69
|
+
<li><a href="sameasConstraint.html">SameAs Constraint</a></li>
|
|
70
|
+
<li><a href="conditionConstraints.html">Condition Constraints</a></li>
|
|
71
|
+
<li><a href="comparisonConstraints.html">Comparison Constrants</a></li>
|
|
72
|
+
<li><a href="typeConstraints.html">Type Constraints</a></li>
|
|
73
|
+
<li><a href="stringConstraints.html">String Constraints</a></li>
|
|
74
|
+
<li><a href="collectionConstraints.html">Collection Constraints</a></li>
|
|
75
|
+
<li><a href="propertyConstraint.html">Property Constraint</a></li>
|
|
76
|
+
<li><a href="compoundConstraints.html">Compound Constraints</a></li>
|
|
77
|
+
<li id="current"><a href="customConstraints.html">Custom Constraints</a></li>
|
|
78
|
+
<li><a href="listMapper.html">List Mapper</a></li>
|
|
79
|
+
</ul>
|
|
80
|
+
</ul>
|
|
81
|
+
<li><a href="attributes.html">Attributes</a></li>
|
|
82
|
+
<li><a href="nunit-console.html">Console Runner</a></li>
|
|
83
|
+
<li><a href="nunit-gui.html">Gui Runner</a></li>
|
|
84
|
+
<li><a href="features.html">Other Features</a></li>
|
|
85
|
+
<li><a href="releaseNotes.html">Release Notes</a></li>
|
|
86
|
+
<li><a href="samples.html">Samples</a></li>
|
|
87
|
+
<li><a href="license.html">License</a></li>
|
|
88
|
+
</ul>
|
|
89
|
+
</ul>
|
|
90
|
+
</div>
|
|
91
|
+
<!-- End of Submenu -->
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
<!-- Standard Footer for NUnit.org -->
|
|
95
|
+
<div id="footer">
|
|
96
|
+
Copyright © 2008 Charlie Poole. All Rights Reserved.
|
|
97
|
+
</div>
|
|
98
|
+
<!-- End of Footer -->
|
|
99
|
+
|
|
100
|
+
</body>
|
|
101
|
+
</html>
|