[NUI] Rebase develnui (DevelNUI only patches --> master) (#3910)
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Devel.Tests.Ubuntu / nunit.framework / Is.cs
1 // ***********************************************************************
2 // Copyright (c) 2009 Charlie Poole
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
11 // 
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
14 // 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 // ***********************************************************************
23 #define PORTABLE
24 #define TIZEN
25 #define NUNIT_FRAMEWORK
26 #define NUNITLITE
27 #define NET_4_5
28 #define PARALLEL
29 using System;
30 using System.Collections;
31 using NUnit.Framework.Constraints;
32
33 namespace NUnit.Framework
34 {
35     /// <summary>
36     /// Helper class with properties and methods that supply
37     /// a number of constraints used in Asserts.
38     /// </summary>
39     public class Is
40     {
41         #region Not
42
43         /// <summary>
44         /// Returns a ConstraintExpression that negates any
45         /// following constraint.
46         /// </summary>
47         public static ConstraintExpression Not
48         {
49             get { return new ConstraintExpression().Not; }
50         }
51
52         #endregion
53
54         #region All
55
56         /// <summary>
57         /// Returns a ConstraintExpression, which will apply
58         /// the following constraint to all members of a collection,
59         /// succeeding if all of them succeed.
60         /// </summary>
61         public static ConstraintExpression All
62         {
63             get { return new ConstraintExpression().All; }
64         }
65
66         #endregion
67
68         #region Null
69
70         /// <summary>
71         /// Returns a constraint that tests for null
72         /// </summary>
73         public static NullConstraint Null
74         {
75             get { return new NullConstraint(); }
76         }
77
78         #endregion
79
80         #region True
81
82         /// <summary>
83         /// Returns a constraint that tests for True
84         /// </summary>
85         public static TrueConstraint True
86         {
87             get { return new TrueConstraint(); }
88         }
89
90         #endregion
91
92         #region False
93
94         /// <summary>
95         /// Returns a constraint that tests for False
96         /// </summary>
97         public static FalseConstraint False
98         {
99             get { return new FalseConstraint(); }
100         }
101
102         #endregion
103
104         #region Positive
105  
106         /// <summary>
107         /// Returns a constraint that tests for a positive value
108         /// </summary>
109         public static GreaterThanConstraint Positive
110         {
111             get { return new GreaterThanConstraint(0); }
112         }
113  
114         #endregion
115  
116         #region Negative
117  
118         /// <summary>
119         /// Returns a constraint that tests for a negative value
120         /// </summary>
121         public static LessThanConstraint Negative
122         {
123             get { return new LessThanConstraint(0); }
124         }
125
126         #endregion
127
128         #region Zero
129
130         /// <summary>
131         /// Returns a constraint that tests for equality with zero
132         /// </summary>
133         public static EqualConstraint Zero
134         {
135             get { return new EqualConstraint(0); }
136         }
137
138         #endregion
139
140         #region NaN
141
142         /// <summary>
143         /// Returns a constraint that tests for NaN
144         /// </summary>
145         public static NaNConstraint NaN
146         {
147             get { return new NaNConstraint(); }
148         }
149
150         #endregion
151
152         #region Empty
153
154         /// <summary>
155         /// Returns a constraint that tests for empty
156         /// </summary>
157         public static EmptyConstraint Empty
158         {
159             get { return new EmptyConstraint(); }
160         }
161
162         #endregion
163
164         #region Unique
165
166         /// <summary>
167         /// Returns a constraint that tests whether a collection 
168         /// contains all unique items.
169         /// </summary>
170         public static UniqueItemsConstraint Unique
171         {
172             get { return new UniqueItemsConstraint(); }
173         }
174
175         #endregion
176
177         #region BinarySerializable
178
179 #if !NETCF && !SILVERLIGHT && !PORTABLE
180         /// <summary>
181         /// Returns a constraint that tests whether an object graph is serializable in binary format.
182         /// </summary>
183         public static BinarySerializableConstraint BinarySerializable
184         {
185             get { return new BinarySerializableConstraint(); }
186         }
187 #endif
188
189         #endregion
190
191         #region XmlSerializable
192
193 #if !SILVERLIGHT && !PORTABLE
194         /// <summary>
195         /// Returns a constraint that tests whether an object graph is serializable in xml format.
196         /// </summary>
197         public static XmlSerializableConstraint XmlSerializable
198         {
199             get { return new XmlSerializableConstraint(); }
200         }
201 #endif
202
203         #endregion
204
205         #region EqualTo
206
207         /// <summary>
208         /// Returns a constraint that tests two items for equality
209         /// </summary>
210         public static EqualConstraint EqualTo(object expected)
211         {
212             return new EqualConstraint(expected);
213         }
214
215         #endregion
216
217         #region SameAs
218
219         /// <summary>
220         /// Returns a constraint that tests that two references are the same object
221         /// </summary>
222         public static SameAsConstraint SameAs(object expected)
223         {
224             return new SameAsConstraint(expected);
225         }
226
227         #endregion
228
229         #region GreaterThan
230
231         /// <summary>
232         /// Returns a constraint that tests whether the
233         /// actual value is greater than the supplied argument
234         /// </summary>
235         public static GreaterThanConstraint GreaterThan(object expected)
236         {
237             return new GreaterThanConstraint(expected);
238         }
239
240         #endregion
241
242         #region GreaterThanOrEqualTo
243
244         /// <summary>
245         /// Returns a constraint that tests whether the
246         /// actual value is greater than or equal to the supplied argument
247         /// </summary>
248         public static GreaterThanOrEqualConstraint GreaterThanOrEqualTo(object expected)
249         {
250             return new GreaterThanOrEqualConstraint(expected);
251         }
252
253         /// <summary>
254         /// Returns a constraint that tests whether the
255         /// actual value is greater than or equal to the supplied argument
256         /// </summary>
257         public static GreaterThanOrEqualConstraint AtLeast(object expected)
258         {
259             return new GreaterThanOrEqualConstraint(expected);
260         }
261
262         #endregion
263
264         #region LessThan
265
266         /// <summary>
267         /// Returns a constraint that tests whether the
268         /// actual value is less than the supplied argument
269         /// </summary>
270         public static LessThanConstraint LessThan(object expected)
271         {
272             return new LessThanConstraint(expected);
273         }
274
275         #endregion
276
277         #region LessThanOrEqualTo
278
279         /// <summary>
280         /// Returns a constraint that tests whether the
281         /// actual value is less than or equal to the supplied argument
282         /// </summary>
283         public static LessThanOrEqualConstraint LessThanOrEqualTo(object expected)
284         {
285             return new LessThanOrEqualConstraint(expected);
286         }
287
288         /// <summary>
289         /// Returns a constraint that tests whether the
290         /// actual value is less than or equal to the supplied argument
291         /// </summary>
292         public static LessThanOrEqualConstraint AtMost(object expected)
293         {
294             return new LessThanOrEqualConstraint(expected);
295         }
296
297         #endregion
298
299         #region TypeOf
300
301         /// <summary>
302         /// Returns a constraint that tests whether the actual
303         /// value is of the exact type supplied as an argument.
304         /// </summary>
305         public static ExactTypeConstraint TypeOf(Type expectedType)
306         {
307             return new ExactTypeConstraint(expectedType);
308         }
309
310         /// <summary>
311         /// Returns a constraint that tests whether the actual
312         /// value is of the exact type supplied as an argument.
313         /// </summary>
314         public static ExactTypeConstraint TypeOf<TExpected>()
315         {
316             return new ExactTypeConstraint(typeof(TExpected));
317         }
318
319         #endregion
320
321         #region InstanceOf
322
323         /// <summary>
324         /// Returns a constraint that tests whether the actual value
325         /// is of the type supplied as an argument or a derived type.
326         /// </summary>
327         public static InstanceOfTypeConstraint InstanceOf(Type expectedType)
328         {
329             return new InstanceOfTypeConstraint(expectedType);
330         }
331
332         /// <summary>
333         /// Returns a constraint that tests whether the actual value
334         /// is of the type supplied as an argument or a derived type.
335         /// </summary>
336         public static InstanceOfTypeConstraint InstanceOf<TExpected>()
337         {
338             return new InstanceOfTypeConstraint(typeof(TExpected));
339         }
340
341         #endregion
342
343         #region AssignableFrom
344
345         /// <summary>
346         /// Returns a constraint that tests whether the actual value
347         /// is assignable from the type supplied as an argument.
348         /// </summary>
349         public static AssignableFromConstraint AssignableFrom(Type expectedType)
350         {
351             return new AssignableFromConstraint(expectedType);
352         }
353
354         /// <summary>
355         /// Returns a constraint that tests whether the actual value
356         /// is assignable from the type supplied as an argument.
357         /// </summary>
358         public static AssignableFromConstraint AssignableFrom<TExpected>()
359         {
360             return new AssignableFromConstraint(typeof(TExpected));
361         }
362
363         #endregion
364
365         #region AssignableTo
366
367         /// <summary>
368         /// Returns a constraint that tests whether the actual value
369         /// is assignable to the type supplied as an argument.
370         /// </summary>
371         public static AssignableToConstraint AssignableTo(Type expectedType)
372         {
373             return new AssignableToConstraint(expectedType);
374         }
375
376         /// <summary>
377         /// Returns a constraint that tests whether the actual value
378         /// is assignable to the type supplied as an argument.
379         /// </summary>
380         public static AssignableToConstraint AssignableTo<TExpected>()
381         {
382             return new AssignableToConstraint(typeof(TExpected));
383         }
384
385         #endregion
386
387         #region EquivalentTo
388
389         /// <summary>
390         /// Returns a constraint that tests whether the actual value
391         /// is a collection containing the same elements as the 
392         /// collection supplied as an argument.
393         /// </summary>
394         public static CollectionEquivalentConstraint EquivalentTo(IEnumerable expected)
395         {
396             return new CollectionEquivalentConstraint(expected);
397         }
398
399         #endregion
400
401         #region SubsetOf
402
403         /// <summary>
404         /// Returns a constraint that tests whether the actual value
405         /// is a subset of the collection supplied as an argument.
406         /// </summary>
407         public static CollectionSubsetConstraint SubsetOf(IEnumerable expected)
408         {
409             return new CollectionSubsetConstraint(expected);
410         }
411
412         #endregion
413
414         #region SupersetOf
415
416         /// <summary>
417         /// Returns a constraint that tests whether the actual value
418         /// is a superset of the collection supplied as an argument.
419         /// </summary>
420         public static CollectionSupersetConstraint SupersetOf(IEnumerable expected)
421         {
422             return new CollectionSupersetConstraint(expected);
423         }
424
425         #endregion
426
427         #region Ordered
428
429         /// <summary>
430         /// Returns a constraint that tests whether a collection is ordered
431         /// </summary>
432         public static CollectionOrderedConstraint Ordered
433         {
434             get { return new CollectionOrderedConstraint(); }
435         }
436
437         #endregion
438
439         #region StringContaining
440
441         /// <summary>
442         /// Returns a constraint that succeeds if the actual
443         /// value contains the substring supplied as an argument.
444         /// </summary>
445         [Obsolete("Deprecated, use Does.Contain")]
446         public static SubstringConstraint StringContaining(string expected)
447         {
448             return new SubstringConstraint(expected);
449         }
450
451         #endregion
452
453         #region StringStarting
454
455         /// <summary>
456         /// Returns a constraint that succeeds if the actual
457         /// value starts with the substring supplied as an argument.
458         /// </summary>
459         [Obsolete("Deprecated, use Does.StartWith")]
460         public static StartsWithConstraint StringStarting(string expected)
461         {
462             return new StartsWithConstraint(expected);
463         }
464
465         #endregion
466
467         #region StringEnding
468
469         /// <summary>
470         /// Returns a constraint that succeeds if the actual
471         /// value ends with the substring supplied as an argument.
472         /// </summary>
473         [Obsolete("Deprecated, use Does.EndWith")]
474         public static EndsWithConstraint StringEnding(string expected)
475         {
476             return new EndsWithConstraint(expected);
477         }
478
479         #endregion
480
481         #region StringMatching
482
483         /// <summary>
484         /// Returns a constraint that succeeds if the actual
485         /// value matches the regular expression supplied as an argument.
486         /// </summary>
487         [Obsolete("Deprecated, use Does.Match")]
488         public static RegexConstraint StringMatching(string pattern)
489         {
490             return new RegexConstraint(pattern);
491         }
492
493         #endregion
494         
495 #if !PORTABLE
496         #region SamePath
497
498         /// <summary>
499         /// Returns a constraint that tests whether the path provided 
500         /// is the same as an expected path after canonicalization.
501         /// </summary>
502         public static SamePathConstraint SamePath(string expected)
503         {
504             return new SamePathConstraint(expected);
505         }
506
507         #endregion
508
509         #region SubPath
510
511         /// <summary>
512         /// Returns a constraint that tests whether the path provided 
513         /// is a subpath of the expected path after canonicalization.
514         /// </summary>
515         public static SubPathConstraint SubPathOf(string expected)
516         {
517             return new SubPathConstraint(expected);
518         }
519
520         #endregion
521
522         #region SamePathOrUnder
523
524         /// <summary>
525         /// Returns a constraint that tests whether the path provided 
526         /// is the same path or under an expected path after canonicalization.
527         /// </summary>
528         public static SamePathOrUnderConstraint SamePathOrUnder(string expected)
529         {
530             return new SamePathOrUnderConstraint(expected);
531         }
532
533         #endregion
534 #endif
535
536         #region InRange
537
538         /// <summary>
539         /// Returns a constraint that tests whether the actual value falls
540         /// inclusively within a specified range.
541         /// </summary>
542         /// <remarks>from must be less than or equal to true</remarks> 
543         /// <param name="from">Inclusive beginning of the range. Must be less than or equal to to.</param>
544         /// <param name="to">Inclusive end of the range. Must be greater than or equal to from.</param>
545         /// <returns></returns>
546         public static RangeConstraint InRange(IComparable from, IComparable to)
547         {
548             return new RangeConstraint(from, to);
549         }
550
551         #endregion
552
553     }
554 }