[1146] | 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 - ListMapper</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>List Mapper (NUnit 2.4.2)</h2>
|
---|
| 28 |
|
---|
| 29 | <p>Unlike Constraint classes, <b>ListMapper</b> is used to modify the actual
|
---|
| 30 | value argument to Assert.That(). It transforms the actual value, which
|
---|
| 31 | must be a collection, creating a new collection to be tested against the
|
---|
| 32 | supplied constraint. Currently, ListMapper supports one transformation: creating
|
---|
| 33 | a collection of property values.
|
---|
| 34 |
|
---|
| 35 | <p>Normally, ListMapper will be used through the <b>List.Map()</b> syntax helper
|
---|
| 36 | or the inherited syntax equivalent, <b>Map()</b>. The following example
|
---|
| 37 | shows three forms of the same assert:
|
---|
| 38 |
|
---|
| 39 | <div class="code"><pre>
|
---|
| 40 | string[] strings = new string[] { "a", "ab", "abc" };
|
---|
| 41 | int[] lengths = new int[] { 1, 2, 3 };
|
---|
| 42 |
|
---|
| 43 | Assert.That(List.Map(strings).Property("Length"),
|
---|
| 44 | Is.EqualTo(lengths));
|
---|
| 45 |
|
---|
| 46 | Assert.That(new ListMapper(strings).Property("Length"),
|
---|
| 47 | Is.EqualTo(lengths));
|
---|
| 48 |
|
---|
| 49 | // Assuming inheritance from AssertionHelper
|
---|
| 50 | Expect(Map(strings).Property("Length"), EqualTo(lengths));
|
---|
| 51 | </pre></div>
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | </div>
|
---|
| 55 |
|
---|
| 56 | <!-- Submenu -->
|
---|
| 57 | <div id="subnav">
|
---|
| 58 | <ul>
|
---|
| 59 | <li><a href="index.html">NUnit 2.5.10</a></li>
|
---|
| 60 | <ul>
|
---|
| 61 | <li><a href="getStarted.html">Getting Started</a></li>
|
---|
| 62 | <li><a href="assertions.html">Assertions</a></li>
|
---|
| 63 | <li><a href="constraintModel.html">Constraints</a></li>
|
---|
| 64 | <ul>
|
---|
| 65 | <li><a href="equalConstraint.html">Equal Constraint</a></li>
|
---|
| 66 | <li><a href="sameasConstraint.html">SameAs Constraint</a></li>
|
---|
| 67 | <li><a href="conditionConstraints.html">Condition Constraints</a></li>
|
---|
| 68 | <li><a href="comparisonConstraints.html">Comparison Constrants</a></li>
|
---|
| 69 | <li><a href="pathConstraints.html">Path Constraints</a></li>
|
---|
| 70 | <li><a href="typeConstraints.html">Type Constraints</a></li>
|
---|
| 71 | <li><a href="stringConstraints.html">String Constraints</a></li>
|
---|
| 72 | <li><a href="collectionConstraints.html">Collection Constraints</a></li>
|
---|
| 73 | <li><a href="propertyConstraint.html">Property Constraint</a></li>
|
---|
| 74 | <li><a href="throwsConstraint.html">Throws Constraint</a></li>
|
---|
| 75 | <li><a href="compoundConstraints.html">Compound Constraints</a></li>
|
---|
| 76 | <li><a href="delayedConstraint.html">Delayed Constraint</a></li>
|
---|
| 77 | <li id="current"><a href="listMapper.html">List Mapper</a></li>
|
---|
| 78 | <li><a href="reusableConstraint.html">Reusable Constraint</a></li>
|
---|
| 79 | </ul>
|
---|
| 80 | <li><a href="attributes.html">Attributes</a></li>
|
---|
| 81 | <li><a href="runningTests.html">Running Tests</a></li>
|
---|
| 82 | <li><a href="extensibility.html">Extensibility</a></li>
|
---|
| 83 | <li><a href="releaseNotes.html">Release Notes</a></li>
|
---|
| 84 | <li><a href="samples.html">Samples</a></li>
|
---|
| 85 | <li><a href="license.html">License</a></li>
|
---|
| 86 | </ul>
|
---|
| 87 | </ul>
|
---|
| 88 | </div>
|
---|
| 89 | <!-- End of Submenu -->
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 | <!-- Standard Footer for NUnit.org -->
|
---|
| 93 | <div id="footer">
|
---|
| 94 | Copyright © 2010 Charlie Poole. All Rights Reserved.
|
---|
| 95 | </div>
|
---|
| 96 | <!-- End of Footer -->
|
---|
| 97 |
|
---|
| 98 | </body>
|
---|
| 99 | </html>
|
---|