1 // ***********************************************************************
2 // Copyright (c) 2014 Charlie Poole
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:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
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 // ***********************************************************************
24 using NUnit.Framework.Constraints;
26 namespace NUnit.Framework
29 /// Helper class with properties and methods that supply
30 /// a number of constraints used in Asserts.
32 public static class Does
37 /// Returns a ConstraintExpression that negates any
38 /// following constraint.
40 public static ConstraintExpression Not
42 get { return new ConstraintExpression().Not; }
49 #if !SILVERLIGHT && !PORTABLE
51 /// Returns a constraint that succeeds if the value
52 /// is a file or directory and it exists.
54 public static FileOrDirectoryExistsConstraint Exist
56 get { return new FileOrDirectoryExistsConstraint(); }
65 /// Returns a new CollectionContainsConstraint checking for the
66 /// presence of a particular object in the collection.
68 public static CollectionContainsConstraint Contain(object expected)
70 return new CollectionContainsConstraint(expected);
74 /// Returns a new ContainsConstraint. This constraint
75 /// will, in turn, make use of the appropriate second-level
76 /// constraint, depending on the type of the actual argument.
77 /// This overload is only used if the item sought is a string,
78 /// since any other type implies that we are looking for a
79 /// collection member.
81 public static ContainsConstraint Contain(string expected)
83 return new ContainsConstraint(expected);
91 /// Returns a constraint that succeeds if the actual
92 /// value starts with the substring supplied as an argument.
94 public static StartsWithConstraint StartWith(string expected)
96 return new StartsWithConstraint(expected);
104 /// Returns a constraint that succeeds if the actual
105 /// value ends with the substring supplied as an argument.
107 public static EndsWithConstraint EndWith(string expected)
109 return new EndsWithConstraint(expected);
117 /// Returns a constraint that succeeds if the actual
118 /// value matches the regular expression supplied as an argument.
120 public static RegexConstraint Match(string pattern)
122 return new RegexConstraint(pattern);