Merge pull request #1336 from esdrubal/datatablereadxmlschema
[mono.git] / mcs / nunit24 / NUnitFramework / framework / SyntaxHelpers / Is.cs
1 // ****************************************************************\r
2 // Copyright 2007, Charlie Poole\r
3 // This is free software licensed under the NUnit license. You may\r
4 // obtain a copy of the license at http://nunit.org/?p=license&r=2.4\r
5 // ****************************************************************\r
6 \r
7 using System;\r
8 using System.Collections;\r
9 using NUnit.Framework.Constraints;\r
10 \r
11 namespace NUnit.Framework.SyntaxHelpers\r
12 {\r
13         /// <summary>\r
14         /// The Is class is a helper class with properties and methods\r
15         /// that supply a number of constraints used in Asserts.\r
16         /// </summary>\r
17         public class Is\r
18         {\r
19                 #region Prefix Operators\r
20                 /// <summary>\r
21                 /// Is.Not returns a ConstraintBuilder that negates\r
22                 /// the constraint that follows it.\r
23                 /// </summary>\r
24                 public static ConstraintBuilder Not\r
25                 {\r
26                         get { return new ConstraintBuilder().Not; }\r
27                 }\r
28 \r
29                 /// <summary>\r
30                 /// Is.All returns a ConstraintBuilder, which will apply\r
31                 /// the following constraint to all members of a collection,\r
32                 /// succeeding if all of them succeed. This property is\r
33                 /// a synonym for Has.AllItems.\r
34                 /// </summary>\r
35                 public static ConstraintBuilder All\r
36                 {\r
37                         get { return new ConstraintBuilder().All; }\r
38                 }\r
39                 #endregion\r
40 \r
41                 #region Constraints Without Arguments\r
42                 /// <summary>\r
43                 /// Is.Null returns a static constraint that tests for null\r
44                 /// </summary>\r
45         public static readonly Constraint Null = new EqualConstraint( null );\r
46                 /// <summary>\r
47                 /// Is.True returns a static constraint that tests whether a value is true\r
48                 /// </summary>\r
49                 public static readonly Constraint True = new EqualConstraint(true);\r
50                 /// <summary>\r
51                 /// Is.False returns a static constraint that tests whether a value is false\r
52                 /// </summary>\r
53                 public static readonly Constraint False = new EqualConstraint(false);\r
54                 /// <summary>\r
55                 /// Is.NaN returns a static constraint that tests whether a value is an NaN\r
56                 /// </summary>\r
57                 public static readonly Constraint NaN = new EqualConstraint(double.NaN);\r
58                 /// <summary>\r
59                 /// Is.Empty returns a static constraint that tests whether a string or collection is empty\r
60                 /// </summary>\r
61                 public static readonly Constraint Empty = new EmptyConstraint();\r
62         /// <summary>\r
63         /// Is.Unique returns a static constraint that tests whether a collection contains all unque items.\r
64         /// </summary>\r
65         public static readonly Constraint Unique = new UniqueItemsConstraint();\r
66         #endregion\r
67 \r
68         #region Constraints with an expected value\r
69 \r
70         #region Equality and Identity\r
71         /// <summary>\r
72         /// Is.EqualTo returns a constraint that tests whether the\r
73         /// actual value equals the supplied argument\r
74         /// </summary>\r
75         /// <param name="expected"></param>\r
76         /// <returns></returns>\r
77         public static EqualConstraint EqualTo(object expected)\r
78         {\r
79             return new EqualConstraint(expected);\r
80         }\r
81                 /// <summary>\r
82                 /// Is.SameAs returns a constraint that tests whether the\r
83                 /// actual value is the same object as the supplied argument.\r
84                 /// </summary>\r
85                 /// <param name="expected"></param>\r
86                 /// <returns></returns>\r
87         public static Constraint SameAs(object expected)\r
88         {\r
89             return new SameAsConstraint(expected);\r
90         }\r
91         #endregion\r
92 \r
93         #region Comparison Constraints\r
94                 /// <summary>\r
95                 /// Is.GreaterThan returns a constraint that tests whether the\r
96                 /// actual value is greater than the suppled argument\r
97                 /// </summary>\r
98                 public static Constraint GreaterThan(IComparable expected)\r
99         {\r
100             return new GreaterThanConstraint(expected);\r
101         }\r
102                 /// <summary>\r
103                 /// Is.GreaterThanOrEqualTo returns a constraint that tests whether the\r
104                 /// actual value is greater than or equal to the suppled argument\r
105                 /// </summary>\r
106                 public static Constraint GreaterThanOrEqualTo(IComparable expected)\r
107         {\r
108             return new GreaterThanOrEqualConstraint(expected);\r
109         }\r
110 \r
111                 /// <summary>\r
112                 /// Is.AtLeast is a synonym for Is.GreaterThanOrEqualTo\r
113                 /// </summary>\r
114                 public static Constraint AtLeast(IComparable expected)\r
115         {\r
116             return GreaterThanOrEqualTo(expected);\r
117         }\r
118 \r
119                 /// <summary>\r
120                 /// Is.LessThan returns a constraint that tests whether the\r
121                 /// actual value is less than the suppled argument\r
122                 /// </summary>\r
123                 public static Constraint LessThan(IComparable expected)\r
124         {\r
125             return new LessThanConstraint(expected);\r
126         }\r
127 \r
128                 /// <summary>\r
129                 /// Is.LessThanOrEqualTo returns a constraint that tests whether the\r
130                 /// actual value is less than or equal to the suppled argument\r
131                 /// </summary>\r
132                 public static Constraint LessThanOrEqualTo(IComparable expected)\r
133         {\r
134             return new LessThanOrEqualConstraint(expected);\r
135         }\r
136 \r
137                 /// <summary>\r
138                 /// Is.AtMost is a synonym for Is.LessThanOrEqualTo\r
139                 /// </summary>\r
140                 public static Constraint AtMost(IComparable expected)\r
141         {\r
142             return LessThanOrEqualTo(expected);\r
143         }\r
144         #endregion\r
145 \r
146                 #region Type Constraints\r
147                 /// <summary>\r
148                 /// Is.TypeOf returns a constraint that tests whether the actual\r
149                 /// value is of the exact type supplied as an argument.\r
150                 /// </summary>\r
151                 public static Constraint TypeOf(Type expectedType)\r
152         {\r
153             return new ExactTypeConstraint(expectedType);\r
154         }\r
155 \r
156                 /// <summary>\r
157                 /// Is.InstanceOfType returns a constraint that tests whether \r
158                 /// the actual value is of the type supplied as an argument\r
159                 /// or a derived type.\r
160                 /// </summary>\r
161                 public static Constraint InstanceOfType(Type expectedType)\r
162         {\r
163             return new InstanceOfTypeConstraint(expectedType);\r
164         }\r
165 \r
166         /// <summary>\r
167         /// Is.AssignableFrom returns a constraint that tests whether\r
168         /// the actual value is assignable from the type supplied as\r
169         /// an argument.\r
170         /// </summary>\r
171         /// <param name="expectedType"></param>\r
172         /// <returns></returns>\r
173         public static Constraint AssignableFrom(Type expectedType)\r
174         {\r
175             return new AssignableFromConstraint(expectedType);\r
176         }\r
177         #endregion\r
178 \r
179                 #region Collection Constraints\r
180                 /// <summary>\r
181                 /// Is.EquivalentTo returns a constraint that tests whether\r
182                 /// the actual value is a collection containing the same\r
183                 /// elements as the collection supplied as an arument\r
184                 /// </summary>\r
185                 public static Constraint EquivalentTo(ICollection expected)\r
186         {\r
187             return new CollectionEquivalentConstraint(expected);\r
188         }\r
189 \r
190                 /// <summary>\r
191                 /// Is.SubsetOf returns a constraint that tests whether\r
192                 /// the actual value is a subset of the collection \r
193                 /// supplied as an arument\r
194                 /// </summary>\r
195                 public static Constraint SubsetOf(ICollection expected)\r
196         {\r
197             return new CollectionSubsetConstraint(expected);\r
198         }\r
199         #endregion\r
200 \r
201         #endregion\r
202     }\r
203 \r
204 \r
205         /// <summary>\r
206         /// The Iz class is a synonym for Is intended for use in VB,\r
207         /// which regards Is as a keyword.\r
208         /// </summary>\r
209         public class Iz : Is\r
210         {\r
211         }\r
212 }\r