[NUI] Rebase develnui (DevelNUI only patches --> master) (#3910)
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Devel.Tests.Ubuntu / nunit.framework / Assert / Assert.Conditions.cs
1 // ***********************************************************************
2 // Copyright (c) 2011 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
24 using System.Collections;
25 using NUnit.Framework.Constraints;
26
27 namespace NUnit.Framework
28 {
29     public partial class Assert
30     {
31         #region True
32
33         /// <summary>
34         /// Asserts that a condition is true. If the condition is false the method throws
35         /// an <see cref="AssertionException"/>.
36         /// </summary>
37         /// <param name="condition">The evaluated condition</param>
38         /// <param name="message">The message to display in case of failure</param>
39         /// <param name="args">Array of objects to be used in formatting the message</param>
40         public static void True(bool? condition, string message, params object[] args)
41         {
42             Assert.That(condition, Is.True ,message, args);
43         }
44
45         /// <summary>
46         /// Asserts that a condition is true. If the condition is false the method throws
47         /// an <see cref="AssertionException"/>.
48         /// </summary>
49         /// <param name="condition">The evaluated condition</param>
50         /// <param name="message">The message to display in case of failure</param>
51         /// <param name="args">Array of objects to be used in formatting the message</param>
52         public static void True(bool condition, string message, params object[] args)
53         {
54            Assert.That(condition, Is.True, message, args);
55         }
56
57         /// <summary>
58         /// Asserts that a condition is true. If the condition is false the method throws
59         /// an <see cref="AssertionException"/>.
60         /// </summary>
61         /// <param name="condition">The evaluated condition</param>
62         public static void True(bool? condition)
63         {
64             Assert.That(condition, Is.True ,null, null);
65         }
66
67         /// <summary>
68         /// Asserts that a condition is true. If the condition is false the method throws
69         /// an <see cref="AssertionException"/>.
70         /// </summary>
71         /// <param name="condition">The evaluated condition</param>
72         public static void True(bool condition)
73         {
74             Assert.That(condition, Is.True ,null, null);
75         }
76
77         /// <summary>
78         /// Asserts that a condition is true. If the condition is false the method throws
79         /// an <see cref="AssertionException"/>.
80         /// </summary>
81         /// <param name="condition">The evaluated condition</param>
82         /// <param name="message">The message to display in case of failure</param>
83         /// <param name="args">Array of objects to be used in formatting the message</param>
84         public static void IsTrue(bool? condition, string message, params object[] args)
85         {
86             Assert.That(condition, Is.True ,message, args);
87         }
88
89         /// <summary>
90         /// Asserts that a condition is true. If the condition is false the method throws
91         /// an <see cref="AssertionException"/>.
92         /// </summary>
93         /// <param name="condition">The evaluated condition</param>
94         /// <param name="message">The message to display in case of failure</param>
95         /// <param name="args">Array of objects to be used in formatting the message</param>
96         public static void IsTrue(bool condition, string message, params object[] args)
97         {
98             Assert.That(condition, Is.True ,message, args);
99         }
100
101         /// <summary>
102         /// Asserts that a condition is true. If the condition is false the method throws
103         /// an <see cref="AssertionException"/>.
104         /// </summary>
105         /// <param name="condition">The evaluated condition</param>
106         public static void IsTrue(bool? condition)
107         {
108             Assert.That(condition, Is.True ,null, null);
109         }
110
111         /// <summary>
112         /// Asserts that a condition is true. If the condition is false the method throws
113         /// an <see cref="AssertionException"/>.
114         /// </summary>
115         /// <param name="condition">The evaluated condition</param>
116         public static void IsTrue(bool condition)
117         {
118             Assert.That(condition, Is.True ,null, null);
119         }
120
121         #endregion
122
123         #region False
124
125         /// <summary>
126         /// Asserts that a condition is false. If the condition is true the method throws
127         /// an <see cref="AssertionException"/>.
128         /// </summary> 
129         /// <param name="condition">The evaluated condition</param>
130         /// <param name="message">The message to display in case of failure</param>
131         /// <param name="args">Array of objects to be used in formatting the message</param>
132         public static void False(bool? condition, string message, params object[] args)
133         {
134             Assert.That(condition, Is.False ,message, args);
135         }
136
137         /// <summary>
138         /// Asserts that a condition is false. If the condition is true the method throws
139         /// an <see cref="AssertionException"/>.
140         /// </summary> 
141         /// <param name="condition">The evaluated condition</param>
142         /// <param name="message">The message to display in case of failure</param>
143         /// <param name="args">Array of objects to be used in formatting the message</param>
144         public static void False(bool condition, string message, params object[] args)
145         {
146             Assert.That(condition, Is.False ,message, args);
147         }
148
149         /// <summary>
150         /// Asserts that a condition is false. If the condition is true the method throws
151         /// an <see cref="AssertionException"/>.
152         /// </summary> 
153         /// <param name="condition">The evaluated condition</param>
154         public static void False(bool? condition)
155         {
156             Assert.That(condition, Is.False ,null, null);
157         }
158
159         /// <summary>
160         /// Asserts that a condition is false. If the condition is true the method throws
161         /// an <see cref="AssertionException"/>.
162         /// </summary> 
163         /// <param name="condition">The evaluated condition</param>
164         public static void False(bool condition)
165         {
166             Assert.That(condition, Is.False ,null, null);
167         }
168
169         /// <summary>
170         /// Asserts that a condition is false. If the condition is true the method throws
171         /// an <see cref="AssertionException"/>.
172         /// </summary> 
173         /// <param name="condition">The evaluated condition</param>
174         /// <param name="message">The message to display in case of failure</param>
175         /// <param name="args">Array of objects to be used in formatting the message</param>
176         public static void IsFalse(bool? condition, string message, params object[] args)
177         {
178             Assert.That(condition, Is.False ,message, args);
179         }
180
181         /// <summary>
182         /// Asserts that a condition is false. If the condition is true the method throws
183         /// an <see cref="AssertionException"/>.
184         /// </summary> 
185         /// <param name="condition">The evaluated condition</param>
186         /// <param name="message">The message to display in case of failure</param>
187         /// <param name="args">Array of objects to be used in formatting the message</param>
188         public static void IsFalse(bool condition, string message, params object[] args)
189         {
190             Assert.That(condition, Is.False ,message, args);
191         }
192
193         /// <summary>
194         /// Asserts that a condition is false. If the condition is true the method throws
195         /// an <see cref="AssertionException"/>.
196         /// </summary> 
197         /// <param name="condition">The evaluated condition</param>
198         public static void IsFalse(bool? condition)
199         {
200             Assert.That(condition, Is.False ,null, null);
201         }
202
203         /// <summary>
204         /// Asserts that a condition is false. If the condition is true the method throws
205         /// an <see cref="AssertionException"/>.
206         /// </summary> 
207         /// <param name="condition">The evaluated condition</param>
208         public static void IsFalse(bool condition)
209         {
210             Assert.That(condition, Is.False ,null, null);
211         }
212
213         #endregion
214
215         #region NotNull
216
217         /// <summary>
218         /// Verifies that the object that is passed in is not equal to <code>null</code>
219         /// If the object is <code>null</code> then an <see cref="AssertionException"/>
220         /// is thrown.
221         /// </summary>
222         /// <param name="anObject">The object that is to be tested</param>
223         /// <param name="message">The message to display in case of failure</param>
224         /// <param name="args">Array of objects to be used in formatting the message</param>
225         public static void NotNull(object anObject, string message, params object[] args)
226         {
227             Assert.That(anObject, Is.Not.Null ,message, args);
228         }
229
230         /// <summary>
231         /// Verifies that the object that is passed in is not equal to <code>null</code>
232         /// If the object is <code>null</code> then an <see cref="AssertionException"/>
233         /// is thrown.
234         /// </summary>
235         /// <param name="anObject">The object that is to be tested</param>
236         public static void NotNull(object anObject)
237         {
238             Assert.That(anObject, Is.Not.Null ,null, null);
239         }
240
241         /// <summary>
242         /// Verifies that the object that is passed in is not equal to <code>null</code>
243         /// If the object is <code>null</code> then an <see cref="AssertionException"/>
244         /// is thrown.
245         /// </summary>
246         /// <param name="anObject">The object that is to be tested</param>
247         /// <param name="message">The message to display in case of failure</param>
248         /// <param name="args">Array of objects to be used in formatting the message</param>
249         public static void IsNotNull(object anObject, string message, params object[] args)
250         {
251             Assert.That(anObject, Is.Not.Null ,message, args);
252         }
253
254         /// <summary>
255         /// Verifies that the object that is passed in is not equal to <code>null</code>
256         /// If the object is <code>null</code> then an <see cref="AssertionException"/>
257         /// is thrown.
258         /// </summary>
259         /// <param name="anObject">The object that is to be tested</param>
260         public static void IsNotNull(object anObject)
261         {
262             Assert.That(anObject, Is.Not.Null ,null, null);
263         }
264
265         #endregion
266
267         #region Null
268
269         /// <summary>
270         /// Verifies that the object that is passed in is equal to <code>null</code>
271         /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
272         /// is thrown.
273         /// </summary>
274         /// <param name="anObject">The object that is to be tested</param>
275         /// <param name="message">The message to display in case of failure</param>
276         /// <param name="args">Array of objects to be used in formatting the message</param>
277         public static void Null(object anObject, string message, params object[] args)
278         {
279             Assert.That(anObject, Is.Null ,message, args);
280         }
281
282         /// <summary>
283         /// Verifies that the object that is passed in is equal to <code>null</code>
284         /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
285         /// is thrown.
286         /// </summary>
287         /// <param name="anObject">The object that is to be tested</param>
288         public static void Null(object anObject)
289         {
290             Assert.That(anObject, Is.Null ,null, null);
291         }
292
293         /// <summary>
294         /// Verifies that the object that is passed in is equal to <code>null</code>
295         /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
296         /// is thrown.
297         /// </summary>
298         /// <param name="anObject">The object that is to be tested</param>
299         /// <param name="message">The message to display in case of failure</param>
300         /// <param name="args">Array of objects to be used in formatting the message</param>
301         public static void IsNull(object anObject, string message, params object[] args)
302         {
303             Assert.That(anObject, Is.Null ,message, args);
304         }
305
306         /// <summary>
307         /// Verifies that the object that is passed in is equal to <code>null</code>
308         /// If the object is not <code>null</code> then an <see cref="AssertionException"/>
309         /// is thrown.
310         /// </summary>
311         /// <param name="anObject">The object that is to be tested</param>
312         public static void IsNull(object anObject)
313         {
314             Assert.That(anObject, Is.Null ,null, null);
315         }
316
317         #endregion
318
319         #region IsNaN
320
321         /// <summary>
322         /// Verifies that the double that is passed in is an <code>NaN</code> value.
323         /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
324         /// is thrown.
325         /// </summary>
326         /// <param name="aDouble">The value that is to be tested</param>
327         /// <param name="message">The message to display in case of failure</param>
328         /// <param name="args">Array of objects to be used in formatting the message</param>
329         public static void IsNaN(double aDouble, string message, params object[] args)
330         {
331             Assert.That(aDouble, Is.NaN ,message, args);
332         }
333
334         /// <summary>
335         /// Verifies that the double that is passed in is an <code>NaN</code> value.
336         /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
337         /// is thrown.
338         /// </summary>
339         /// <param name="aDouble">The value that is to be tested</param>
340         public static void IsNaN(double aDouble)
341         {
342             Assert.That(aDouble, Is.NaN ,null, null);
343         }
344
345         /// <summary>
346         /// Verifies that the double that is passed in is an <code>NaN</code> value.
347         /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
348         /// is thrown.
349         /// </summary>
350         /// <param name="aDouble">The value that is to be tested</param>
351         /// <param name="message">The message to display in case of failure</param>
352         /// <param name="args">Array of objects to be used in formatting the message</param>
353         public static void IsNaN(double? aDouble, string message, params object[] args)
354         {
355             Assert.That(aDouble, Is.NaN ,message, args);
356         }
357
358         /// <summary>
359         /// Verifies that the double that is passed in is an <code>NaN</code> value.
360         /// If the object is not <code>NaN</code> then an <see cref="AssertionException"/>
361         /// is thrown.
362         /// </summary>
363         /// <param name="aDouble">The value that is to be tested</param>
364         public static void IsNaN(double? aDouble)
365         {
366             Assert.That(aDouble, Is.NaN ,null, null);
367         }
368
369         #endregion
370
371         #region IsEmpty
372
373         #region String
374
375         /// <summary>
376         /// Assert that a string is empty - that is equal to string.Empty
377         /// </summary>
378         /// <param name="aString">The string to be tested</param>
379         /// <param name="message">The message to display in case of failure</param>
380         /// <param name="args">Array of objects to be used in formatting the message</param>
381         public static void IsEmpty(string aString, string message, params object[] args)
382         {
383             Assert.That(aString, new EmptyStringConstraint() ,message, args);
384         }
385
386         /// <summary>
387         /// Assert that a string is empty - that is equal to string.Empty
388         /// </summary>
389         /// <param name="aString">The string to be tested</param>
390         public static void IsEmpty(string aString)
391         {
392             Assert.That(aString, new EmptyStringConstraint() ,null, null);
393         }
394
395         #endregion
396
397         #region Collection
398
399         /// <summary>
400         /// Assert that an array, list or other collection is empty
401         /// </summary>
402         /// <param name="collection">An array, list or other collection implementing ICollection</param>
403         /// <param name="message">The message to display in case of failure</param>
404         /// <param name="args">Array of objects to be used in formatting the message</param>
405         public static void IsEmpty(IEnumerable collection, string message, params object[] args)
406         {
407             Assert.That(collection, new EmptyCollectionConstraint() ,message, args);
408         }
409
410         /// <summary>
411         /// Assert that an array, list or other collection is empty
412         /// </summary>
413         /// <param name="collection">An array, list or other collection implementing ICollection</param>
414         public static void IsEmpty(IEnumerable collection)
415         {
416             Assert.That(collection, new EmptyCollectionConstraint() ,null, null);
417         }
418
419         #endregion
420
421         #endregion
422
423         #region IsNotEmpty
424
425         #region String
426
427         /// <summary>
428         /// Assert that a string is not empty - that is not equal to string.Empty
429         /// </summary>
430         /// <param name="aString">The string to be tested</param>
431         /// <param name="message">The message to display in case of failure</param>
432         /// <param name="args">Array of objects to be used in formatting the message</param>
433         public static void IsNotEmpty(string aString, string message, params object[] args)
434         {
435             Assert.That(aString, Is.Not.Empty ,message, args);
436         }
437
438         /// <summary>
439         /// Assert that a string is not empty - that is not equal to string.Empty
440         /// </summary>
441         /// <param name="aString">The string to be tested</param>
442         public static void IsNotEmpty(string aString)
443         {
444             Assert.That(aString, Is.Not.Empty ,null, null);
445         }
446
447         #endregion
448
449         #region Collection
450
451         /// <summary>
452         /// Assert that an array, list or other collection is not empty
453         /// </summary>
454         /// <param name="collection">An array, list or other collection implementing ICollection</param>
455         /// <param name="message">The message to display in case of failure</param>
456         /// <param name="args">Array of objects to be used in formatting the message</param>
457         public static void IsNotEmpty(IEnumerable collection, string message, params object[] args)
458         {
459             Assert.That(collection, Is.Not.Empty ,message, args);
460         }
461
462         /// <summary>
463         /// Assert that an array, list or other collection is not empty
464         /// </summary>
465         /// <param name="collection">An array, list or other collection implementing ICollection</param>
466         public static void IsNotEmpty(IEnumerable collection)
467         {
468             Assert.That(collection, Is.Not.Empty ,null, null);
469         }
470
471         #endregion
472
473         #endregion
474     }
475 }