1 | <!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
---|
2 | <html>
|
---|
3 | <!-- Standard Head Part -->
|
---|
4 | <head>
|
---|
5 | <title>NUnit - ConditionConstraints</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>Condition Constraints (NUnit 2.4)</h2>
|
---|
28 |
|
---|
29 | <p>ConditionConstraints test a specific condition and are named for the condition
|
---|
30 | they test. They verify that the actual value satisfies the condition. The
|
---|
31 | following condition helpers are provided.
|
---|
32 |
|
---|
33 | <h3>NullConstraint</h3>
|
---|
34 |
|
---|
35 | <h4>Action</h4>
|
---|
36 | <p>Tests that a value is Null.
|
---|
37 |
|
---|
38 | <h4>Constructor</h4>
|
---|
39 | <div class="code"><pre>
|
---|
40 | NullConstraint()
|
---|
41 | </pre></div>
|
---|
42 |
|
---|
43 | <h4>Syntax</h4>
|
---|
44 | <div class="code"><pre>
|
---|
45 | Is.Null
|
---|
46 | </pre></div>
|
---|
47 |
|
---|
48 | <h4>Examples of Use</h4>
|
---|
49 | <div class="code"><pre>
|
---|
50 | Assert.That( anObject, Is.Null );
|
---|
51 | Assert.That( anObject, Is.Not.Null );
|
---|
52 | </pre></div>
|
---|
53 |
|
---|
54 | <h3>TrueConstraint</h3>
|
---|
55 |
|
---|
56 | <h4>Action</h4>
|
---|
57 | <p>Tests that a value is true.
|
---|
58 |
|
---|
59 | <h4>Constructor</h4>
|
---|
60 | <div class="code"><pre>
|
---|
61 | TrueConstraint()
|
---|
62 | </pre></div>
|
---|
63 |
|
---|
64 | <h4>Syntax</h4>
|
---|
65 | <div class="code"><pre>
|
---|
66 | Is.True
|
---|
67 | </pre></div>
|
---|
68 |
|
---|
69 | <h4>Example of Use</h4>
|
---|
70 | <div class="code"><pre>
|
---|
71 | Assert.That( condition, Is.True );
|
---|
72 | </pre></div>
|
---|
73 |
|
---|
74 | <h3>FalseConstraint</h3>
|
---|
75 |
|
---|
76 | <h4>Action</h4>
|
---|
77 | <p>Tests that a value is false.
|
---|
78 |
|
---|
79 | <h4>Constructor</h4>
|
---|
80 | <div class="code"><pre>
|
---|
81 | FalseConstraint()
|
---|
82 | </pre></div>
|
---|
83 |
|
---|
84 | <h4>Syntax</h4>
|
---|
85 | <div class="code"><pre>
|
---|
86 | Is.False
|
---|
87 | </pre></div>
|
---|
88 |
|
---|
89 | <h4>Example of Use</h4>
|
---|
90 | <div class="code"><pre>
|
---|
91 | Assert.That( condition, Is.False );
|
---|
92 | </pre></div>
|
---|
93 |
|
---|
94 | <h3>NaNConstraint</h3>
|
---|
95 |
|
---|
96 | <h4>Action</h4>
|
---|
97 | <p>Tests that a value is floating-point NaN.
|
---|
98 |
|
---|
99 | <h4>Constructor</h4>
|
---|
100 | <div class="code"><pre>
|
---|
101 | NaNConstraint()
|
---|
102 | </pre></div>
|
---|
103 |
|
---|
104 | <h4>Syntax</h4>
|
---|
105 | <div class="code"><pre>
|
---|
106 | Is.NaN
|
---|
107 | </pre></div>
|
---|
108 |
|
---|
109 | <h4>Examples of Use</h4>
|
---|
110 | <div class="code"><pre>
|
---|
111 | Assert.That( aDouble, Is.NaN );
|
---|
112 | Assert.That( aDouble, Is.Not.NaN );
|
---|
113 | </pre></div>
|
---|
114 |
|
---|
115 | <h3>EmptyConstraint</h3>
|
---|
116 |
|
---|
117 | <h4>Action</h4>
|
---|
118 | <p>Tests that an object is an empty string, directory or collection.
|
---|
119 |
|
---|
120 | <h4>Constructor</h4>
|
---|
121 | <div class="code"><pre>
|
---|
122 | EmptyConstraint()
|
---|
123 | </pre></div>
|
---|
124 |
|
---|
125 | <h4>Syntax</h4>
|
---|
126 | <div class="code"><pre>
|
---|
127 | Is.Empty
|
---|
128 | </pre></div>
|
---|
129 |
|
---|
130 | <h4>Examples of Use</h4>
|
---|
131 | <div class="code"><pre>
|
---|
132 | Assert.That( aString, Is.Empty );
|
---|
133 | Assert.Thst( dirInfo, Is.Empty );
|
---|
134 | Assert.That( collection, Is.Empty );
|
---|
135 | </pre></div>
|
---|
136 |
|
---|
137 | <h4>Notes</h4>
|
---|
138 | <ol>
|
---|
139 | <li><b>EmptyConstraint</b> creates and uses either an <b>EmptyStringConstraint</b>,
|
---|
140 | <b>EmptyDirectoryConstraint</b> or <b>EmptyCollectionConstraint</b> depending on
|
---|
141 | the argument tested.
|
---|
142 | <li>A <b>DirectoryInfo</b> argument is required in order to test for an empty directory.
|
---|
143 | To test whether a string represents a directory path, you must first construct
|
---|
144 | a <b>DirectoryInfo</b>.
|
---|
145 | </ol>
|
---|
146 |
|
---|
147 | <h3>UniqueItemsConstraint</h3>
|
---|
148 |
|
---|
149 | <h4>Action</h4>
|
---|
150 | <p>Tests that an array, collection or other IEnumerable is composed
|
---|
151 | of unique items with no duplicates.
|
---|
152 |
|
---|
153 | <h4>Constructor</h4>
|
---|
154 | <div class="code"><pre>
|
---|
155 | UniqueItemsConstraint()
|
---|
156 | </pre></div>
|
---|
157 |
|
---|
158 | <h4>Syntax</h4>
|
---|
159 | <div class="code"><pre>
|
---|
160 | Is.Unique
|
---|
161 | </pre></div>
|
---|
162 |
|
---|
163 | <h4>Example of Use</h4>
|
---|
164 |
|
---|
165 | <div class="code"><pre>
|
---|
166 | Assert.That( collection, Is.Unique );
|
---|
167 | </pre></div>
|
---|
168 | </div>
|
---|
169 |
|
---|
170 | <!-- Submenu -->
|
---|
171 | <div id="subnav">
|
---|
172 | <ul>
|
---|
173 | <li><a href="index.html">NUnit 2.5.10</a></li>
|
---|
174 | <ul>
|
---|
175 | <li><a href="getStarted.html">Getting Started</a></li>
|
---|
176 | <li><a href="assertions.html">Assertions</a></li>
|
---|
177 | <li><a href="constraintModel.html">Constraints</a></li>
|
---|
178 | <ul>
|
---|
179 | <li><a href="equalConstraint.html">Equal Constraint</a></li>
|
---|
180 | <li><a href="sameasConstraint.html">SameAs Constraint</a></li>
|
---|
181 | <li id="current"><a href="conditionConstraints.html">Condition Constraints</a></li>
|
---|
182 | <li><a href="comparisonConstraints.html">Comparison Constrants</a></li>
|
---|
183 | <li><a href="pathConstraints.html">Path Constraints</a></li>
|
---|
184 | <li><a href="typeConstraints.html">Type Constraints</a></li>
|
---|
185 | <li><a href="stringConstraints.html">String Constraints</a></li>
|
---|
186 | <li><a href="collectionConstraints.html">Collection Constraints</a></li>
|
---|
187 | <li><a href="propertyConstraint.html">Property Constraint</a></li>
|
---|
188 | <li><a href="throwsConstraint.html">Throws Constraint</a></li>
|
---|
189 | <li><a href="compoundConstraints.html">Compound Constraints</a></li>
|
---|
190 | <li><a href="delayedConstraint.html">Delayed Constraint</a></li>
|
---|
191 | <li><a href="listMapper.html">List Mapper</a></li>
|
---|
192 | <li><a href="reusableConstraint.html">Reusable Constraint</a></li>
|
---|
193 | </ul>
|
---|
194 | <li><a href="attributes.html">Attributes</a></li>
|
---|
195 | <li><a href="runningTests.html">Running Tests</a></li>
|
---|
196 | <li><a href="extensibility.html">Extensibility</a></li>
|
---|
197 | <li><a href="releaseNotes.html">Release Notes</a></li>
|
---|
198 | <li><a href="samples.html">Samples</a></li>
|
---|
199 | <li><a href="license.html">License</a></li>
|
---|
200 | </ul>
|
---|
201 | </ul>
|
---|
202 | </div>
|
---|
203 | <!-- End of Submenu -->
|
---|
204 |
|
---|
205 |
|
---|
206 | <!-- Standard Footer for NUnit.org -->
|
---|
207 | <div id="footer">
|
---|
208 | Copyright © 2010 Charlie Poole. All Rights Reserved.
|
---|
209 | </div>
|
---|
210 | <!-- End of Footer -->
|
---|
211 |
|
---|
212 | </body>
|
---|
213 | </html>
|
---|