This file is indexed.

/usr/share/doc/nunit/html/testCaseSource.html is in libnunit-doc 2.6.0.12051+dfsg-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<!-- Standard Head Part -->
<head>
<title>NUnit - TestCaseSource</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-US">
<meta name="norton-safeweb-site-verification" content="tb6xj01p4hgo5x-8wscsmq633y11-e6nhk-bnb5d987bseanyp6p0uew-pec8j963qlzj32k5x9h3r2q7wh-vmy8bbhek5lnpp5w4p8hocouuq39e09jrkihdtaeknua" />
<link rel="stylesheet" type="text/css" href="nunit.css">
<link rel="shortcut icon" href="favicon.ico">
</head>
<!-- End Standard Head Part -->

<body>

<!-- Standard Header for NUnit.org -->
<div id="header">
  <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a>
  <div id="nav">
    <a href="http://www.nunit.org">NUnit</a>
    <a class="active" href="index.html">Documentation</a>
  </div>
</div>
<!-- End of Header -->

<div id="content">

<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE -->

<h3>TestCaseSourceAttribute (NUnit 2.5)</h3>

<p><b>TestCaseSourceAttribute</b> is used on a parameterized test method to
identify the property, method or field that will provide the required 
arguments. The attribute has two public constructors.

<div class="code">
<pre>
TestCaseSourceAttribute(Type sourceType, string sourceName);
TestCaseSourceAttribute(string sourceName);
</pre>
</div>

<p>If <b>sourceType</b> is specified, it represents the class that provides
the test cases. It must have a default constructor.

<p>If <b>sourceType</b> is not specified, the class containing the test
method is used. NUnit will construct it using either the default constructor
or - if arguments are provided - the appropriate constructor for those 
arguments.

<p>The <b>sourceName</b> argument represents the name of the source used
to provide test cases. It has the following characteristics:
<ul>
<li>It may be a field, property or method.
<li>It may be either an instance or a static member.
<li>It must return an IEnumerable or a type that implements IEnumerable.
<li>The individual items returned by the enumerator must be compatible
    with the signature of the method on which the attribute appears.
	The rules for this are described in the next section.
</ul>

<p><b>TestCaseSourceAttribute</b> supports one named parameter:

<dl>
<dt><b>Category</b>
<dd>Used to assign one or more categories to every test case returned from this source.
</dl>

<h3>Constructing Test Cases</h3>

<p>In constructing tests, NUnit uses each item returned by
the enumerator as follows:
<ol>

<li><p>If it is an object implementing <b>NUnit.Framework.ITestCaseData</b>, 
its properties are used to provide the test case. In NUnit 2.5, this is
done using reflection to allow compatibility with earlier versions that
did not implement <b>ITestCaseData</b>.

<p>The following public fields or properties are used:
  <p><dl>
  <dt><b>Arguments</b>
  <dd>An <b>object[]</b> representing the arguments to the method
  <dt><b>Categories</b>
  <dd>An IList of categories to be applied to the test case.
  <dt><b>Description</b>
  <dd>Sets the description property of the test
  <dt><b>ExpectedException</b>
  <dd>Specifies a the Type of an exception that should be thrown by this invocation
  <dt><b>ExpectedExceptionName</b>
  <dd>Specifies a the FullName of an exception that should be thrown by this invocation
  <dt><b>Ignored</b>
  <dd>If true, the test case is ignored.
  <dt><b>IgnoreReason</b>
  <dd>Specifies the reason for ignoring this test case. If set to a non-empty
      string, then the test is ignored.
  <dt><b>Properties</b>
  <dd>An IDictionary of properties to be applied to the test case.
      Note that the values provided must be compatible with PropertiesAttribute.
	  In particular, use of custom types or enums will cause problems.
  <dt><b>Result</b>
  <dd>The expected result to be returned from the method, which must have
      a compatible return type.
  <dt><b>TestName</b>
  <dd>Provides a name for the test. If not specified, a name is generated based on 
      the method name and the arguments provided
  </dl>

<p>
<li><p>If the test has a single argument and the returned value matches the type of
that argument it is used directly.

<li><p>If it is an <b>object[]</b>, its members are used to provide
the arguments for the method, as in this example, which returns
arguments from a named static field.

<div class="code">
<pre>[Test, TestCaseSource("DivideCases")]
public void DivideTest(int n, int d, int q)
{
    Assert.AreEqual( q, n / d );
}

static object[] DivideCases =
{
    new object[] { 12, 3, 4 },
    new object[] { 12, 2, 6 },
    new object[] { 12, 4, 3 } 
};
</pre></div>

<li><p>If it is an array of some other type, NUnit can use it provided
that the arguments to the method are all of that type. For example,
the above code could be modified to make the three nested arrays 
of type int[].

<li><p>If anything else is returned, it is used directly as the sole 
argument to the method. This allows NUnit to give an error message
in cases where the method requires a different number arguments or
an argument of a different type.
This can also eliminate a bit of extra typing by the programmer, 
as in this example:

<div class="code"><pre>
static int[] EvenNumbers = new int[] { 2, 4, 6, 8 };

[Test, TestCaseSource("EvenNumbers")]
public void TestMethod(int num)
{
    Assert.IsTrue( num % 2 == 0 );
}
</pre></div>

</ol>

<h3>TestCaseData Class</h3>

<p>Although any object implementing <b>ITestCaseData</b> may be used to
   provide extended test case information, NUnit provides the <b>TestCaseData</b> 
   class for this purpose. The following    example returns <b>TestCaseData</b> 
   instances from a data source in a separately defined class.

<div class="code">
<pre>[TestFixture]
public class MyTests
{
  [Test,TestCaseSource(typeof(MyFactoryClass),"TestCases")]
  public int DivideTest(int n, int d)
  {
    return n/d;
  }
	
  ...
}

public class MyFactoryClass
{
  public static IEnumerable TestCases
  {
    get
    {
      yield return new TestCaseData( 12, 3 ).Returns( 4 );
      yield return new TestCaseData( 12, 2 ).Returns( 6 );
      yield return new TestCaseData( 12, 4 ).Returns( 3 );
      yield return new TestCaseData( 0, 0 )
        .Throws(typeof(DivideByZeroException))
        .SetName("DivideByZero")
        .SetDescription("An exception is expected");
    }
  }  
}
</div>

<p>This example uses the fluent interface supported by <b>TestCaseData</b>
to make the program more readable. The last yield statement above  is equivalent to

<div class="code"><pre>
      TestCaseData data = new TestCaseData(0,0);
      data.ExpectedException = typeof(DivideByZeroException;
      data.TestName = "DivideByZero";
      data.Description = "An exception is expected";
      yield return data;
</pre>
</div> 

<p><b>TestCaseData</b> supports the following properties
and methods, which may be appended to an instance in any order.

<p>
<dl>
  <dt><b>.Ignore()</b>
  <dd>Causes the test case to be ignored.
  <dt><b>.Ignore(string)</b>
  <dd>Causes the test case to be ignored with a reason specified.
  <dt><b>.MakeExplicit()</b>
  <dd>Causes the test case to be marked explicit.
  <dt><b>.MakeExplicit(string)</b>
  <dd>Causes the test case to be marked explicit and specifies the reason for doing so.
  <dt><b>.Returns</b>
  <dd>The expected result to be returned from the method, which must have
      a compatible return type.
  <dt><b>.SetCategory(string)</b>
  <dd>Applies a category to the test
  <dt><b>.SetDescription(string)</b>
  <dd>Sets the description property of the test
  <dt><b>.SetName(string)</b>
  <dd>Provides a name for the test. If not specified, a name is generated based on 
      the method name and the arguments provided
  <dt><b>.SetProperty(string, string)</b>
  <dt><b>.SetProperty(string, int)</b>
  <dt><b>.SetProperty(string, double)</b>
  <dd>Applies a named property and value to the test
  <dt><b>.Throws(Type)</b>
  <dt><b>.Throws(string)</b>
  <dd>Specifies a the Type or FullName of an exception that should be thrown by this invocation
</dl>

<h3>Order of Execution</h3>

<p>In NUnit 2.5, individual test cases are sorted alphabetically and executed in
   that order. With NUnit 2.5.1, the individual cases are not sorted, but are
   executed in the order in which NUnit discovers them. This order does <b>not</b>
   follow the lexical order of the attributes and will often vary between different
   compilers or different versions of the CLR.
   
<p>As a result, when <b>TestCaseSourceAttribute</b> appears multiple times on a 
   method or when other data-providing attributes are used in combination with 
   <b>TestCaseSourceAttribute</b>, the order of the test cases is undefined.

<p>However, when a single <b>TestCaseSourceAttribute</b> is used by itself, 
   the order of the tests follows exactly the order in which the test cases 
   are returned from the source.
   
<h3>Note on Object Construction</h3>

<p>NUnit locates the test cases at the time the tests are loaded, creates
instances of each class with non-static sources and builds a list of 
tests to be executed. Each source object is only created once at this
time and is destroyed after all tests are loaded. 

<p>If the data source is in the test fixture itself, the object is created
using the appropriate constructor for the fixture parameters provided on
the <b>TestFixtureAttribute</b> or
the default constructor if no parameters were specified. Since this object
is destroyed before the tests are run, no communication is possible between
these two phases - or between different runs - except through the parameters
themselves.

   

</div>

<!-- Submenu -->
<div id="subnav">
<ul>
<li><a href="index.html">NUnit 2.6</a></li>
<ul>
<li><a href="getStarted.html">Getting&nbsp;Started</a></li>
<li><a href="writingTests.html">Writing&nbsp;Tests</a></li>
<ul>
<li><a href="assertions.html">Assertions</a></li>
<li><a href="attributes.html">Attributes</a></li>
<ul>
<li><a href="actionAttributes.html">Action&nbsp;Attributes</a></li>
<li><a href="category.html">Category</a></li>
<li><a href="combinatorial.html">Combinatorial</a></li>
<li><a href="culture.html">Culture</a></li>
<li><a href="datapoint.html">Datapoint(s)</a></li>
<li><a href="description.html">Description</a></li>
<li><a href="exception.html">Exception</a></li>
<li><a href="explicit.html">Explicit</a></li>
<li><a href="ignore.html">Ignore</a></li>
<li><a href="maxtime.html">Maxtime</a></li>
<li><a href="pairwise.html">Pairwise</a></li>
<li><a href="platform.html">Platform</a></li>
<li><a href="property.html">Property</a></li>
<li><a href="random.html">Random</a></li>
<li><a href="range.html">Range</a></li>
<li><a href="repeat.html">Repeat</a></li>
<li><a href="requiredAddin.html">RequiredAddin</a></li>
<li><a href="requiresMTA.html">Requires&nbsp;MTA</a></li>
<li><a href="requiresSTA.html">Requires&nbsp;STA</a></li>
<li><a href="requiresThread.html">Requires&nbsp;Thread</a></li>
<li><a href="sequential.html">Sequential</a></li>
<li><a href="setCulture.html">SetCulture</a></li>
<li><a href="setUICulture.html">SetUICulture</a></li>
<li><a href="setup.html">Setup</a></li>
<li><a href="setupFixture.html">SetupFixture</a></li>
<li><a href="suite.html">Suite</a></li>
<li><a href="teardown.html">Teardown</a></li>
<li><a href="test.html">Test</a></li>
<li><a href="testCase.html">TestCase</a></li>
<li id="current"><a href="testCaseSource.html">TestCaseSource</a></li>
<li><a href="testFixture.html">TestFixture</a></li>
<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li>
<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li>
<li><a href="theory.html">Theory</a></li>
<li><a href="timeout.html">Timeout</a></li>
<li><a href="values.html">Values</a></li>
<li><a href="valueSource.html">ValueSource</a></li>
</ul>
<li><a href="constraintModel.html">Constraints</a></li>
<li><a href="testContext.html">Test&nbsp;Context</a></li>
</ul>
<li><a href="runningTests.html">Running&nbsp;Tests</a></li>
<li><a href="extensibility.html">Extensibility</a></li>
<li><a href="releaseNotes.html">Release&nbsp;Notes</a></li>
<li><a href="samples.html">Samples</a></li>
<li><a href="license.html">License</a></li>
</ul>
<li><a href="vsTestAdapter.html">NUnit&nbsp;Test&nbsp;Adapter&nbsp;0.90</a></li>
<ul>
<li><a href="vsTestAdapterLicense.html">License</a></li>
</ul>
<li><a href="&r=2.6.html"></a></li>
<li><a href="&r=2.6.html"></a></li>
</ul>
</div>
<!-- End of Submenu -->


<!-- Standard Footer for NUnit.org -->
<div id="footer">
  Copyright &copy; 2012 Charlie Poole. All Rights Reserved.
</div>
<!-- End of Footer -->

</body>
</html>