~ubuntu-branches/debian/sid/nunit/sid

« back to all changes in this revision

Viewing changes to src/NUnitFramework/framework/Is.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2014-09-16 13:43:36 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140916134336-kjxz48tty6lx2ja5
Tags: 2.6.3+dfsg-1
* [c7bd1b5] Imported Upstream version 2.6.3+dfsg
* [bcb4bf8] Move nunit-console-runner to GAC-installed libnunit2.6, 
  don't treat it as a private lib. This lib is signed, and treated 
  as a GAC lib by consumers such as MonoDevelop.
* [7f08e99] Bump version to 2.6.3 as required
* [84535eb] Refreshed patches
* [8479f61] Split package up into per-assembly packages. This makes 
  ABI tracking easier in the future, as we can meaningfully have GAC 
  policy for cases where ABI isn't truly bumped, and no policy for 
  cases where it is. For example, if nunit.framework bumps ABI but 
  nunit.core does not, previously we would need to rebuild everything 
  using NUnit, but under the new split packaging, that rebuild would 
  not be needed for apps only using nunit.core.
* [17a7dc7] Add missing nunit.mocks.dll to nunit.pc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ****************************************************************
2
 
// Copyright 2009, Charlie Poole
3
 
// This is free software licensed under the NUnit license. You may
4
 
// obtain a copy of the license at http://nunit.org
5
 
// ****************************************************************
6
 
 
7
 
using System;
8
 
using System.Collections;
9
 
using NUnit.Framework.Constraints;
10
 
 
11
 
namespace NUnit.Framework
12
 
{
13
 
    /// <summary>
14
 
    /// Helper class with properties and methods that supply
15
 
    /// a number of constraints used in Asserts.
16
 
    /// </summary>
17
 
    public class Is
18
 
    {
19
 
        #region Not
20
 
 
21
 
        /// <summary>
22
 
        /// Returns a ConstraintExpression that negates any
23
 
        /// following constraint.
24
 
        /// </summary>
25
 
        public static ConstraintExpression Not
26
 
        {
27
 
            get { return new ConstraintExpression().Not; }
28
 
        }
29
 
 
30
 
        #endregion
31
 
 
32
 
        #region All
33
 
 
34
 
        /// <summary>
35
 
        /// Returns a ConstraintExpression, which will apply
36
 
        /// the following constraint to all members of a collection,
37
 
        /// succeeding if all of them succeed.
38
 
        /// </summary>
39
 
        public static ConstraintExpression All
40
 
        {
41
 
            get { return new ConstraintExpression().All; }
42
 
        }
43
 
 
44
 
        #endregion
45
 
 
46
 
        #region Null
47
 
 
48
 
        /// <summary>
49
 
        /// Returns a constraint that tests for null
50
 
        /// </summary>
51
 
        public static NullConstraint Null
52
 
        {
53
 
            get { return new NullConstraint(); }
54
 
        }
55
 
 
56
 
        #endregion
57
 
 
58
 
        #region True
59
 
 
60
 
        /// <summary>
61
 
        /// Returns a constraint that tests for True
62
 
        /// </summary>
63
 
        public static TrueConstraint True
64
 
        {
65
 
            get { return new TrueConstraint(); }
66
 
        }
67
 
 
68
 
        #endregion
69
 
 
70
 
        #region False
71
 
 
72
 
        /// <summary>
73
 
        /// Returns a constraint that tests for False
74
 
        /// </summary>
75
 
        public static FalseConstraint False
76
 
        {
77
 
            get { return new FalseConstraint(); }
78
 
        }
79
 
 
80
 
        #endregion
81
 
 
82
 
        #region Positive
83
 
 
84
 
        /// <summary>
85
 
        /// Returns a constraint that tests for a positive value
86
 
        /// </summary>
87
 
        public static GreaterThanConstraint Positive
88
 
        {
89
 
            get { return new GreaterThanConstraint(0); }
90
 
        }
91
 
 
92
 
        #endregion
93
 
 
94
 
        #region Negative
95
 
 
96
 
        /// <summary>
97
 
        /// Returns a constraint that tests for a negative value
98
 
        /// </summary>
99
 
        public static LessThanConstraint Negative
100
 
        {
101
 
            get { return new LessThanConstraint(0); }
102
 
        }
103
 
 
104
 
        #endregion
105
 
 
106
 
        #region NaN
107
 
 
108
 
        /// <summary>
109
 
        /// Returns a constraint that tests for NaN
110
 
        /// </summary>
111
 
        public static NaNConstraint NaN
112
 
        {
113
 
            get { return new NaNConstraint(); }
114
 
        }
115
 
 
116
 
        #endregion
117
 
 
118
 
        #region Empty
119
 
 
120
 
        /// <summary>
121
 
        /// Returns a constraint that tests for empty
122
 
        /// </summary>
123
 
        public static EmptyConstraint Empty
124
 
        {
125
 
            get { return new EmptyConstraint(); }
126
 
        }
127
 
 
128
 
        #endregion
129
 
 
130
 
        #region Unique
131
 
 
132
 
        /// <summary>
133
 
        /// Returns a constraint that tests whether a collection 
134
 
        /// contains all unique items.
135
 
        /// </summary>
136
 
        public static UniqueItemsConstraint Unique
137
 
        {
138
 
            get { return new UniqueItemsConstraint(); }
139
 
        }
140
 
 
141
 
        #endregion
142
 
 
143
 
        #region BinarySerializable
144
 
 
145
 
        /// <summary>
146
 
        /// Returns a constraint that tests whether an object graph is serializable in binary format.
147
 
        /// </summary>
148
 
        public static BinarySerializableConstraint BinarySerializable
149
 
        {
150
 
            get { return new BinarySerializableConstraint(); }
151
 
        }
152
 
 
153
 
        #endregion
154
 
 
155
 
        #region XmlSerializable
156
 
 
157
 
        /// <summary>
158
 
        /// Returns a constraint that tests whether an object graph is serializable in xml format.
159
 
        /// </summary>
160
 
        public static XmlSerializableConstraint XmlSerializable
161
 
        {
162
 
            get { return new XmlSerializableConstraint(); }
163
 
        }
164
 
 
165
 
        #endregion
166
 
 
167
 
        #region EqualTo
168
 
 
169
 
        /// <summary>
170
 
        /// Returns a constraint that tests two items for equality
171
 
        /// </summary>
172
 
        public static EqualConstraint EqualTo(object expected)
173
 
        {
174
 
            return new EqualConstraint(expected);
175
 
        }
176
 
 
177
 
        #endregion
178
 
 
179
 
        #region SameAs
180
 
 
181
 
        /// <summary>
182
 
        /// Returns a constraint that tests that two references are the same object
183
 
        /// </summary>
184
 
        public static SameAsConstraint SameAs(object expected)
185
 
        {
186
 
            return new SameAsConstraint(expected);
187
 
        }
188
 
 
189
 
        #endregion
190
 
 
191
 
        #region GreaterThan
192
 
 
193
 
        /// <summary>
194
 
        /// Returns a constraint that tests whether the
195
 
        /// actual value is greater than the suppled argument
196
 
        /// </summary>
197
 
        public static GreaterThanConstraint GreaterThan(object expected)
198
 
        {
199
 
            return new GreaterThanConstraint(expected);
200
 
        }
201
 
 
202
 
        #endregion
203
 
 
204
 
        #region GreaterThanOrEqualTo
205
 
 
206
 
        /// <summary>
207
 
        /// Returns a constraint that tests whether the
208
 
        /// actual value is greater than or equal to the suppled argument
209
 
        /// </summary>
210
 
        public static GreaterThanOrEqualConstraint GreaterThanOrEqualTo(object expected)
211
 
        {
212
 
            return new GreaterThanOrEqualConstraint(expected);
213
 
        }
214
 
 
215
 
        /// <summary>
216
 
        /// Returns a constraint that tests whether the
217
 
        /// actual value is greater than or equal to the suppled argument
218
 
        /// </summary>
219
 
        public static GreaterThanOrEqualConstraint AtLeast(object expected)
220
 
        {
221
 
            return new GreaterThanOrEqualConstraint(expected);
222
 
        }
223
 
 
224
 
        #endregion
225
 
 
226
 
        #region LessThan
227
 
 
228
 
        /// <summary>
229
 
        /// Returns a constraint that tests whether the
230
 
        /// actual value is less than the suppled argument
231
 
        /// </summary>
232
 
        public static LessThanConstraint LessThan(object expected)
233
 
        {
234
 
            return new LessThanConstraint(expected);
235
 
        }
236
 
 
237
 
        #endregion
238
 
 
239
 
        #region LessThanOrEqualTo
240
 
 
241
 
        /// <summary>
242
 
        /// Returns a constraint that tests whether the
243
 
        /// actual value is less than or equal to the suppled argument
244
 
        /// </summary>
245
 
        public static LessThanOrEqualConstraint LessThanOrEqualTo(object expected)
246
 
        {
247
 
            return new LessThanOrEqualConstraint(expected);
248
 
        }
249
 
 
250
 
        /// <summary>
251
 
        /// Returns a constraint that tests whether the
252
 
        /// actual value is less than or equal to the suppled argument
253
 
        /// </summary>
254
 
        public static LessThanOrEqualConstraint AtMost(object expected)
255
 
        {
256
 
            return new LessThanOrEqualConstraint(expected);
257
 
        }
258
 
 
259
 
        #endregion
260
 
 
261
 
        #region TypeOf
262
 
 
263
 
        /// <summary>
264
 
        /// Returns a constraint that tests whether the actual
265
 
        /// value is of the exact type supplied as an argument.
266
 
        /// </summary>
267
 
        public static ExactTypeConstraint TypeOf(Type expectedType)
268
 
        {
269
 
            return new ExactTypeConstraint(expectedType);
270
 
        }
271
 
 
272
 
#if CLR_2_0 || CLR_4_0
273
 
        /// <summary>
274
 
        /// Returns a constraint that tests whether the actual
275
 
        /// value is of the exact type supplied as an argument.
276
 
        /// </summary>
277
 
        public static ExactTypeConstraint TypeOf<T>()
278
 
        {
279
 
            return new ExactTypeConstraint(typeof(T));
280
 
        }
281
 
#endif
282
 
 
283
 
        #endregion
284
 
 
285
 
        #region InstanceOf
286
 
 
287
 
        /// <summary>
288
 
        /// Returns a constraint that tests whether the actual value
289
 
        /// is of the type supplied as an argument or a derived type.
290
 
        /// </summary>
291
 
        public static InstanceOfTypeConstraint InstanceOf(Type expectedType)
292
 
        {
293
 
            return new InstanceOfTypeConstraint(expectedType);
294
 
        }
295
 
 
296
 
#if CLR_2_0 || CLR_4_0
297
 
        /// <summary>
298
 
        /// Returns a constraint that tests whether the actual value
299
 
        /// is of the type supplied as an argument or a derived type.
300
 
        /// </summary>
301
 
        public static InstanceOfTypeConstraint InstanceOf<T>()
302
 
        {
303
 
            return new InstanceOfTypeConstraint(typeof(T));
304
 
        }
305
 
#endif
306
 
 
307
 
        /// <summary>
308
 
        /// Returns a constraint that tests whether the actual value
309
 
        /// is of the type supplied as an argument or a derived type.
310
 
        /// </summary>
311
 
        [Obsolete("Use InstanceOf(expectedType)")]
312
 
        public static InstanceOfTypeConstraint InstanceOfType(Type expectedType)
313
 
        {
314
 
            return new InstanceOfTypeConstraint(expectedType);
315
 
        }
316
 
 
317
 
#if CLR_2_0 || CLR_4_0
318
 
        /// <summary>
319
 
        /// Returns a constraint that tests whether the actual value
320
 
        /// is of the type supplied as an argument or a derived type.
321
 
        /// </summary>
322
 
        [Obsolete("Use InstanceOf<T>()")]
323
 
        public static InstanceOfTypeConstraint InstanceOfType<T>()
324
 
        {
325
 
            return new InstanceOfTypeConstraint(typeof(T));
326
 
        }
327
 
#endif
328
 
 
329
 
        #endregion
330
 
 
331
 
        #region AssignableFrom
332
 
 
333
 
        /// <summary>
334
 
        /// Returns a constraint that tests whether the actual value
335
 
        /// is assignable from the type supplied as an argument.
336
 
        /// </summary>
337
 
        public static AssignableFromConstraint AssignableFrom(Type expectedType)
338
 
        {
339
 
            return new AssignableFromConstraint(expectedType);
340
 
        }
341
 
 
342
 
#if CLR_2_0 || CLR_4_0
343
 
        /// <summary>
344
 
        /// Returns a constraint that tests whether the actual value
345
 
        /// is assignable from the type supplied as an argument.
346
 
        /// </summary>
347
 
        public static AssignableFromConstraint AssignableFrom<T>()
348
 
        {
349
 
            return new AssignableFromConstraint(typeof(T));
350
 
        }
351
 
#endif
352
 
 
353
 
        #endregion
354
 
 
355
 
        #region AssignableTo
356
 
 
357
 
        /// <summary>
358
 
        /// Returns a constraint that tests whether the actual value
359
 
        /// is assignable from the type supplied as an argument.
360
 
        /// </summary>
361
 
        public static AssignableToConstraint AssignableTo(Type expectedType)
362
 
        {
363
 
            return new AssignableToConstraint(expectedType);
364
 
        }
365
 
 
366
 
#if CLR_2_0 || CLR_4_0
367
 
        /// <summary>
368
 
        /// Returns a constraint that tests whether the actual value
369
 
        /// is assignable from the type supplied as an argument.
370
 
        /// </summary>
371
 
        public static AssignableToConstraint AssignableTo<T>()
372
 
        {
373
 
            return new AssignableToConstraint(typeof(T));
374
 
        }
375
 
#endif
376
 
 
377
 
        #endregion
378
 
 
379
 
        #region EquivalentTo
380
 
 
381
 
        /// <summary>
382
 
        /// Returns a constraint that tests whether the actual value
383
 
        /// is a collection containing the same elements as the 
384
 
        /// collection supplied as an argument.
385
 
        /// </summary>
386
 
        public static CollectionEquivalentConstraint EquivalentTo(IEnumerable expected)
387
 
        {
388
 
            return new CollectionEquivalentConstraint(expected);
389
 
        }
390
 
 
391
 
        #endregion
392
 
 
393
 
        #region SubsetOf
394
 
 
395
 
        /// <summary>
396
 
        /// Returns a constraint that tests whether the actual value
397
 
        /// is a subset of the collection supplied as an argument.
398
 
        /// </summary>
399
 
        public static CollectionSubsetConstraint SubsetOf(IEnumerable expected)
400
 
        {
401
 
            return new CollectionSubsetConstraint(expected);
402
 
        }
403
 
 
404
 
        #endregion
405
 
 
406
 
        #region Ordered
407
 
 
408
 
        /// <summary>
409
 
        /// Returns a constraint that tests whether a collection is ordered
410
 
        /// </summary>
411
 
        public static CollectionOrderedConstraint Ordered
412
 
        {
413
 
            get { return new CollectionOrderedConstraint(); }
414
 
        }
415
 
 
416
 
        #endregion
417
 
 
418
 
        #region StringContaining
419
 
 
420
 
        /// <summary>
421
 
        /// Returns a constraint that succeeds if the actual
422
 
        /// value contains the substring supplied as an argument.
423
 
        /// </summary>
424
 
        public static SubstringConstraint StringContaining(string expected)
425
 
        {
426
 
            return new SubstringConstraint(expected);
427
 
        }
428
 
 
429
 
        #endregion
430
 
 
431
 
        #region StringStarting
432
 
 
433
 
        /// <summary>
434
 
        /// Returns a constraint that succeeds if the actual
435
 
        /// value starts with the substring supplied as an argument.
436
 
        /// </summary>
437
 
        public static StartsWithConstraint StringStarting(string expected)
438
 
        {
439
 
            return new StartsWithConstraint(expected);
440
 
        }
441
 
 
442
 
        #endregion
443
 
 
444
 
        #region StringEnding
445
 
 
446
 
        /// <summary>
447
 
        /// Returns a constraint that succeeds if the actual
448
 
        /// value ends with the substring supplied as an argument.
449
 
        /// </summary>
450
 
        public static EndsWithConstraint StringEnding(string expected)
451
 
        {
452
 
            return new EndsWithConstraint(expected);
453
 
        }
454
 
 
455
 
        #endregion
456
 
 
457
 
        #region StringMatching
458
 
 
459
 
        /// <summary>
460
 
        /// Returns a constraint that succeeds if the actual
461
 
        /// value matches the Regex pattern supplied as an argument.
462
 
        /// </summary>
463
 
        public static RegexConstraint StringMatching(string pattern)
464
 
        {
465
 
            return new RegexConstraint(pattern);
466
 
        }
467
 
 
468
 
        #endregion
469
 
 
470
 
        #region SamePath
471
 
 
472
 
        /// <summary>
473
 
        /// Returns a constraint that tests whether the path provided 
474
 
        /// is the same as an expected path after canonicalization.
475
 
        /// </summary>
476
 
        public static SamePathConstraint SamePath(string expected)
477
 
        {
478
 
            return new SamePathConstraint(expected);
479
 
        }
480
 
 
481
 
        #endregion
482
 
 
483
 
        #region SubPath
484
 
 
485
 
        /// <summary>
486
 
        /// Returns a constraint that tests whether the path provided 
487
 
        /// is the same path or under an expected path after canonicalization.
488
 
        /// </summary>
489
 
        public static SubPathConstraint SubPath(string expected)
490
 
        {
491
 
            return new SubPathConstraint(expected);
492
 
        }
493
 
 
494
 
        #endregion
495
 
 
496
 
        #region SamePathOrUnder
497
 
 
498
 
        /// <summary>
499
 
        /// Returns a constraint that tests whether the path provided 
500
 
        /// is the same path or under an expected path after canonicalization.
501
 
        /// </summary>
502
 
        public static SamePathOrUnderConstraint SamePathOrUnder(string expected)
503
 
        {
504
 
            return new SamePathOrUnderConstraint(expected);
505
 
        }
506
 
 
507
 
        #endregion
508
 
 
509
 
        #region InRange
510
 
 
511
 
#if !CLR_2_0 && !CLR_4_0
512
 
        /// <summary>
513
 
        /// Returns a constraint that tests whether the actual value falls 
514
 
        /// within a specified range.
515
 
        /// </summary>
516
 
        public static RangeConstraint InRange(IComparable from, IComparable to)
517
 
        {
518
 
            return new RangeConstraint(from, to);
519
 
        }
520
 
#endif
521
 
 
522
 
        #endregion
523
 
 
524
 
        #region InRange<T>
525
 
 
526
 
#if CLR_2_0 || CLR_4_0
527
 
        /// <summary>
528
 
        /// Returns a constraint that tests whether the actual value falls 
529
 
        /// within a specified range.
530
 
        /// </summary>
531
 
        public static RangeConstraint<T> InRange<T>(T from, T to) where T : IComparable<T>
532
 
        {
533
 
            return new RangeConstraint<T>(from, to);
534
 
        }
535
 
#endif
536
 
 
537
 
        #endregion
538
 
 
539
 
    }
540
 
}
 
1
// ****************************************************************
 
2
// Copyright 2009, Charlie Poole
 
3
// This is free software licensed under the NUnit license. You may
 
4
// obtain a copy of the license at http://nunit.org
 
5
// ****************************************************************
 
6
 
 
7
using System;
 
8
using System.Collections;
 
9
using NUnit.Framework.Constraints;
 
10
 
 
11
namespace NUnit.Framework
 
12
{
 
13
    /// <summary>
 
14
    /// Helper class with properties and methods that supply
 
15
    /// a number of constraints used in Asserts.
 
16
    /// </summary>
 
17
    public class Is
 
18
    {
 
19
        #region Not
 
20
 
 
21
        /// <summary>
 
22
        /// Returns a ConstraintExpression that negates any
 
23
        /// following constraint.
 
24
        /// </summary>
 
25
        public static ConstraintExpression Not
 
26
        {
 
27
            get { return new ConstraintExpression().Not; }
 
28
        }
 
29
 
 
30
        #endregion
 
31
 
 
32
        #region All
 
33
 
 
34
        /// <summary>
 
35
        /// Returns a ConstraintExpression, which will apply
 
36
        /// the following constraint to all members of a collection,
 
37
        /// succeeding if all of them succeed.
 
38
        /// </summary>
 
39
        public static ConstraintExpression All
 
40
        {
 
41
            get { return new ConstraintExpression().All; }
 
42
        }
 
43
 
 
44
        #endregion
 
45
 
 
46
        #region Null
 
47
 
 
48
        /// <summary>
 
49
        /// Returns a constraint that tests for null
 
50
        /// </summary>
 
51
        public static NullConstraint Null
 
52
        {
 
53
            get { return new NullConstraint(); }
 
54
        }
 
55
 
 
56
        #endregion
 
57
 
 
58
        #region True
 
59
 
 
60
        /// <summary>
 
61
        /// Returns a constraint that tests for True
 
62
        /// </summary>
 
63
        public static TrueConstraint True
 
64
        {
 
65
            get { return new TrueConstraint(); }
 
66
        }
 
67
 
 
68
        #endregion
 
69
 
 
70
        #region False
 
71
 
 
72
        /// <summary>
 
73
        /// Returns a constraint that tests for False
 
74
        /// </summary>
 
75
        public static FalseConstraint False
 
76
        {
 
77
            get { return new FalseConstraint(); }
 
78
        }
 
79
 
 
80
        #endregion
 
81
 
 
82
        #region Positive
 
83
 
 
84
        /// <summary>
 
85
        /// Returns a constraint that tests for a positive value
 
86
        /// </summary>
 
87
        public static GreaterThanConstraint Positive
 
88
        {
 
89
            get { return new GreaterThanConstraint(0); }
 
90
        }
 
91
 
 
92
        #endregion
 
93
 
 
94
        #region Negative
 
95
 
 
96
        /// <summary>
 
97
        /// Returns a constraint that tests for a negative value
 
98
        /// </summary>
 
99
        public static LessThanConstraint Negative
 
100
        {
 
101
            get { return new LessThanConstraint(0); }
 
102
        }
 
103
 
 
104
        #endregion
 
105
 
 
106
        #region NaN
 
107
 
 
108
        /// <summary>
 
109
        /// Returns a constraint that tests for NaN
 
110
        /// </summary>
 
111
        public static NaNConstraint NaN
 
112
        {
 
113
            get { return new NaNConstraint(); }
 
114
        }
 
115
 
 
116
        #endregion
 
117
 
 
118
        #region Empty
 
119
 
 
120
        /// <summary>
 
121
        /// Returns a constraint that tests for empty
 
122
        /// </summary>
 
123
        public static EmptyConstraint Empty
 
124
        {
 
125
            get { return new EmptyConstraint(); }
 
126
        }
 
127
 
 
128
        #endregion
 
129
 
 
130
        #region Unique
 
131
 
 
132
        /// <summary>
 
133
        /// Returns a constraint that tests whether a collection 
 
134
        /// contains all unique items.
 
135
        /// </summary>
 
136
        public static UniqueItemsConstraint Unique
 
137
        {
 
138
            get { return new UniqueItemsConstraint(); }
 
139
        }
 
140
 
 
141
        #endregion
 
142
 
 
143
        #region BinarySerializable
 
144
 
 
145
        /// <summary>
 
146
        /// Returns a constraint that tests whether an object graph is serializable in binary format.
 
147
        /// </summary>
 
148
        public static BinarySerializableConstraint BinarySerializable
 
149
        {
 
150
            get { return new BinarySerializableConstraint(); }
 
151
        }
 
152
 
 
153
        #endregion
 
154
 
 
155
        #region XmlSerializable
 
156
 
 
157
        /// <summary>
 
158
        /// Returns a constraint that tests whether an object graph is serializable in xml format.
 
159
        /// </summary>
 
160
        public static XmlSerializableConstraint XmlSerializable
 
161
        {
 
162
            get { return new XmlSerializableConstraint(); }
 
163
        }
 
164
 
 
165
        #endregion
 
166
 
 
167
        #region EqualTo
 
168
 
 
169
        /// <summary>
 
170
        /// Returns a constraint that tests two items for equality
 
171
        /// </summary>
 
172
        public static EqualConstraint EqualTo(object expected)
 
173
        {
 
174
            return new EqualConstraint(expected);
 
175
        }
 
176
 
 
177
        #endregion
 
178
 
 
179
        #region SameAs
 
180
 
 
181
        /// <summary>
 
182
        /// Returns a constraint that tests that two references are the same object
 
183
        /// </summary>
 
184
        public static SameAsConstraint SameAs(object expected)
 
185
        {
 
186
            return new SameAsConstraint(expected);
 
187
        }
 
188
 
 
189
        #endregion
 
190
 
 
191
        #region GreaterThan
 
192
 
 
193
        /// <summary>
 
194
        /// Returns a constraint that tests whether the
 
195
        /// actual value is greater than the suppled argument
 
196
        /// </summary>
 
197
        public static GreaterThanConstraint GreaterThan(object expected)
 
198
        {
 
199
            return new GreaterThanConstraint(expected);
 
200
        }
 
201
 
 
202
        #endregion
 
203
 
 
204
        #region GreaterThanOrEqualTo
 
205
 
 
206
        /// <summary>
 
207
        /// Returns a constraint that tests whether the
 
208
        /// actual value is greater than or equal to the suppled argument
 
209
        /// </summary>
 
210
        public static GreaterThanOrEqualConstraint GreaterThanOrEqualTo(object expected)
 
211
        {
 
212
            return new GreaterThanOrEqualConstraint(expected);
 
213
        }
 
214
 
 
215
        /// <summary>
 
216
        /// Returns a constraint that tests whether the
 
217
        /// actual value is greater than or equal to the suppled argument
 
218
        /// </summary>
 
219
        public static GreaterThanOrEqualConstraint AtLeast(object expected)
 
220
        {
 
221
            return new GreaterThanOrEqualConstraint(expected);
 
222
        }
 
223
 
 
224
        #endregion
 
225
 
 
226
        #region LessThan
 
227
 
 
228
        /// <summary>
 
229
        /// Returns a constraint that tests whether the
 
230
        /// actual value is less than the suppled argument
 
231
        /// </summary>
 
232
        public static LessThanConstraint LessThan(object expected)
 
233
        {
 
234
            return new LessThanConstraint(expected);
 
235
        }
 
236
 
 
237
        #endregion
 
238
 
 
239
        #region LessThanOrEqualTo
 
240
 
 
241
        /// <summary>
 
242
        /// Returns a constraint that tests whether the
 
243
        /// actual value is less than or equal to the suppled argument
 
244
        /// </summary>
 
245
        public static LessThanOrEqualConstraint LessThanOrEqualTo(object expected)
 
246
        {
 
247
            return new LessThanOrEqualConstraint(expected);
 
248
        }
 
249
 
 
250
        /// <summary>
 
251
        /// Returns a constraint that tests whether the
 
252
        /// actual value is less than or equal to the suppled argument
 
253
        /// </summary>
 
254
        public static LessThanOrEqualConstraint AtMost(object expected)
 
255
        {
 
256
            return new LessThanOrEqualConstraint(expected);
 
257
        }
 
258
 
 
259
        #endregion
 
260
 
 
261
        #region TypeOf
 
262
 
 
263
        /// <summary>
 
264
        /// Returns a constraint that tests whether the actual
 
265
        /// value is of the exact type supplied as an argument.
 
266
        /// </summary>
 
267
        public static ExactTypeConstraint TypeOf(Type expectedType)
 
268
        {
 
269
            return new ExactTypeConstraint(expectedType);
 
270
        }
 
271
 
 
272
#if CLR_2_0 || CLR_4_0
 
273
        /// <summary>
 
274
        /// Returns a constraint that tests whether the actual
 
275
        /// value is of the exact type supplied as an argument.
 
276
        /// </summary>
 
277
        public static ExactTypeConstraint TypeOf<T>()
 
278
        {
 
279
            return new ExactTypeConstraint(typeof(T));
 
280
        }
 
281
#endif
 
282
 
 
283
        #endregion
 
284
 
 
285
        #region InstanceOf
 
286
 
 
287
        /// <summary>
 
288
        /// Returns a constraint that tests whether the actual value
 
289
        /// is of the type supplied as an argument or a derived type.
 
290
        /// </summary>
 
291
        public static InstanceOfTypeConstraint InstanceOf(Type expectedType)
 
292
        {
 
293
            return new InstanceOfTypeConstraint(expectedType);
 
294
        }
 
295
 
 
296
#if CLR_2_0 || CLR_4_0
 
297
        /// <summary>
 
298
        /// Returns a constraint that tests whether the actual value
 
299
        /// is of the type supplied as an argument or a derived type.
 
300
        /// </summary>
 
301
        public static InstanceOfTypeConstraint InstanceOf<T>()
 
302
        {
 
303
            return new InstanceOfTypeConstraint(typeof(T));
 
304
        }
 
305
#endif
 
306
 
 
307
        /// <summary>
 
308
        /// Returns a constraint that tests whether the actual value
 
309
        /// is of the type supplied as an argument or a derived type.
 
310
        /// </summary>
 
311
        [Obsolete("Use InstanceOf(expectedType)")]
 
312
        public static InstanceOfTypeConstraint InstanceOfType(Type expectedType)
 
313
        {
 
314
            return new InstanceOfTypeConstraint(expectedType);
 
315
        }
 
316
 
 
317
#if CLR_2_0 || CLR_4_0
 
318
        /// <summary>
 
319
        /// Returns a constraint that tests whether the actual value
 
320
        /// is of the type supplied as an argument or a derived type.
 
321
        /// </summary>
 
322
        [Obsolete("Use InstanceOf<T>()")]
 
323
        public static InstanceOfTypeConstraint InstanceOfType<T>()
 
324
        {
 
325
            return new InstanceOfTypeConstraint(typeof(T));
 
326
        }
 
327
#endif
 
328
 
 
329
        #endregion
 
330
 
 
331
        #region AssignableFrom
 
332
 
 
333
        /// <summary>
 
334
        /// Returns a constraint that tests whether the actual value
 
335
        /// is assignable from the type supplied as an argument.
 
336
        /// </summary>
 
337
        public static AssignableFromConstraint AssignableFrom(Type expectedType)
 
338
        {
 
339
            return new AssignableFromConstraint(expectedType);
 
340
        }
 
341
 
 
342
#if CLR_2_0 || CLR_4_0
 
343
        /// <summary>
 
344
        /// Returns a constraint that tests whether the actual value
 
345
        /// is assignable from the type supplied as an argument.
 
346
        /// </summary>
 
347
        public static AssignableFromConstraint AssignableFrom<T>()
 
348
        {
 
349
            return new AssignableFromConstraint(typeof(T));
 
350
        }
 
351
#endif
 
352
 
 
353
        #endregion
 
354
 
 
355
        #region AssignableTo
 
356
 
 
357
        /// <summary>
 
358
        /// Returns a constraint that tests whether the actual value
 
359
        /// is assignable from the type supplied as an argument.
 
360
        /// </summary>
 
361
        public static AssignableToConstraint AssignableTo(Type expectedType)
 
362
        {
 
363
            return new AssignableToConstraint(expectedType);
 
364
        }
 
365
 
 
366
#if CLR_2_0 || CLR_4_0
 
367
        /// <summary>
 
368
        /// Returns a constraint that tests whether the actual value
 
369
        /// is assignable from the type supplied as an argument.
 
370
        /// </summary>
 
371
        public static AssignableToConstraint AssignableTo<T>()
 
372
        {
 
373
            return new AssignableToConstraint(typeof(T));
 
374
        }
 
375
#endif
 
376
 
 
377
        #endregion
 
378
 
 
379
        #region EquivalentTo
 
380
 
 
381
        /// <summary>
 
382
        /// Returns a constraint that tests whether the actual value
 
383
        /// is a collection containing the same elements as the 
 
384
        /// collection supplied as an argument.
 
385
        /// </summary>
 
386
        public static CollectionEquivalentConstraint EquivalentTo(IEnumerable expected)
 
387
        {
 
388
            return new CollectionEquivalentConstraint(expected);
 
389
        }
 
390
 
 
391
        #endregion
 
392
 
 
393
        #region SubsetOf
 
394
 
 
395
        /// <summary>
 
396
        /// Returns a constraint that tests whether the actual value
 
397
        /// is a subset of the collection supplied as an argument.
 
398
        /// </summary>
 
399
        public static CollectionSubsetConstraint SubsetOf(IEnumerable expected)
 
400
        {
 
401
            return new CollectionSubsetConstraint(expected);
 
402
        }
 
403
 
 
404
        #endregion
 
405
 
 
406
        #region Ordered
 
407
 
 
408
        /// <summary>
 
409
        /// Returns a constraint that tests whether a collection is ordered
 
410
        /// </summary>
 
411
        public static CollectionOrderedConstraint Ordered
 
412
        {
 
413
            get { return new CollectionOrderedConstraint(); }
 
414
        }
 
415
 
 
416
        #endregion
 
417
 
 
418
        #region StringContaining
 
419
 
 
420
        /// <summary>
 
421
        /// Returns a constraint that succeeds if the actual
 
422
        /// value contains the substring supplied as an argument.
 
423
        /// </summary>
 
424
        public static SubstringConstraint StringContaining(string expected)
 
425
        {
 
426
            return new SubstringConstraint(expected);
 
427
        }
 
428
 
 
429
        #endregion
 
430
 
 
431
        #region StringStarting
 
432
 
 
433
        /// <summary>
 
434
        /// Returns a constraint that succeeds if the actual
 
435
        /// value starts with the substring supplied as an argument.
 
436
        /// </summary>
 
437
        public static StartsWithConstraint StringStarting(string expected)
 
438
        {
 
439
            return new StartsWithConstraint(expected);
 
440
        }
 
441
 
 
442
        #endregion
 
443
 
 
444
        #region StringEnding
 
445
 
 
446
        /// <summary>
 
447
        /// Returns a constraint that succeeds if the actual
 
448
        /// value ends with the substring supplied as an argument.
 
449
        /// </summary>
 
450
        public static EndsWithConstraint StringEnding(string expected)
 
451
        {
 
452
            return new EndsWithConstraint(expected);
 
453
        }
 
454
 
 
455
        #endregion
 
456
 
 
457
        #region StringMatching
 
458
 
 
459
        /// <summary>
 
460
        /// Returns a constraint that succeeds if the actual
 
461
        /// value matches the regular expression supplied as an argument.
 
462
        /// </summary>
 
463
        public static RegexConstraint StringMatching(string pattern)
 
464
        {
 
465
            return new RegexConstraint(pattern);
 
466
        }
 
467
 
 
468
        #endregion
 
469
 
 
470
        #region SamePath
 
471
 
 
472
        /// <summary>
 
473
        /// Returns a constraint that tests whether the path provided 
 
474
        /// is the same as an expected path after canonicalization.
 
475
        /// </summary>
 
476
        public static SamePathConstraint SamePath(string expected)
 
477
        {
 
478
            return new SamePathConstraint(expected);
 
479
        }
 
480
 
 
481
        #endregion
 
482
 
 
483
        #region SubPath
 
484
 
 
485
        /// <summary>
 
486
        /// Returns a constraint that tests whether the path provided 
 
487
        /// is under an expected path after canonicalization.
 
488
        /// </summary>
 
489
        public static SubPathConstraint SubPath(string expected)
 
490
        {
 
491
            return new SubPathConstraint(expected);
 
492
        }
 
493
 
 
494
        #endregion
 
495
 
 
496
        #region SamePathOrUnder
 
497
 
 
498
        /// <summary>
 
499
        /// Returns a constraint that tests whether the path provided 
 
500
        /// is the same path or under an expected path after canonicalization.
 
501
        /// </summary>
 
502
        public static SamePathOrUnderConstraint SamePathOrUnder(string expected)
 
503
        {
 
504
            return new SamePathOrUnderConstraint(expected);
 
505
        }
 
506
 
 
507
        #endregion
 
508
 
 
509
        #region InRange
 
510
 
 
511
#if CLR_2_0 || CLR_4_0
 
512
        /// <summary>
 
513
        /// Returns a constraint that tests whether the actual value falls 
 
514
        /// within a specified range.
 
515
        /// </summary>
 
516
        public static RangeConstraint<T> InRange<T>(T from, T to) where T : IComparable<T>
 
517
        {
 
518
            return new RangeConstraint<T>(from, to);
 
519
        }
 
520
#else
 
521
        /// <summary>
 
522
        /// Returns a constraint that tests whether the actual value falls 
 
523
        /// within a specified range.
 
524
        /// </summary>
 
525
        public static RangeConstraint InRange(IComparable from, IComparable to)
 
526
        {
 
527
            return new RangeConstraint(from, to);
 
528
        }
 
529
#endif
 
530
 
 
531
        #endregion
 
532
    }
 
533
}