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
// ****************************************************************
8
using System.Collections;
9
using NUnit.Framework.Constraints;
11
namespace NUnit.Framework
14
/// Helper class with static methods used to supply constraints
15
/// that operate on strings.
17
[Obsolete("Use Is class for string constraints")]
23
/// Returns a ConstraintExpression, which will apply
24
/// the following constraint to all members of a collection,
25
/// succeeding if all of them succeed.
27
[Obsolete("Use Is.All")]
28
public static ConstraintExpression All
30
get { return new ConstraintExpression().All; }
38
/// Returns a constraint that succeeds if the actual
39
/// value contains the substring supplied as an argument.
41
[Obsolete("Use Is.StringContaining")]
42
public static SubstringConstraint Contains(string expected)
44
return new SubstringConstraint(expected);
49
#region DoesNotContain
52
/// Returns a constraint that fails if the actual
53
/// value contains the substring supplied as an argument.
55
[Obsolete("Use Is.Not.StringContaining")]
56
public static SubstringConstraint DoesNotContain(string expected)
58
return new ConstraintExpression().Not.ContainsSubstring(expected);
66
/// Returns a constraint that succeeds if the actual
67
/// value starts with the substring supplied as an argument.
69
[Obsolete("Use Is.StringStarting")]
70
public static StartsWithConstraint StartsWith(string expected)
72
return new StartsWithConstraint(expected);
77
#region DoesNotStartWith
80
/// Returns a constraint that fails if the actual
81
/// value starts with the substring supplied as an argument.
83
public static StartsWithConstraint DoesNotStartWith(string expected)
85
return new ConstraintExpression().Not.StartsWith(expected);
93
/// Returns a constraint that succeeds if the actual
94
/// value ends with the substring supplied as an argument.
96
[Obsolete("Use Is.StringEnding")]
97
public static EndsWithConstraint EndsWith(string expected)
99
return new EndsWithConstraint(expected);
104
#region DoesNotEndWith
107
/// Returns a constraint that fails if the actual
108
/// value ends with the substring supplied as an argument.
110
public static EndsWithConstraint DoesNotEndWith(string expected)
112
return new ConstraintExpression().Not.EndsWith(expected);
120
/// Returns a constraint that succeeds if the actual
121
/// value matches the Regex pattern supplied as an argument.
123
[Obsolete("Use Is.StringMatching")]
124
public static RegexConstraint Matches(string pattern)
126
return new RegexConstraint(pattern);
134
/// Returns a constraint that fails if the actual
135
/// value matches the pattern supplied as an argument.
138
public static RegexConstraint DoesNotMatch(string pattern)
140
return new ConstraintExpression().Not.Matches(pattern);
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
// ****************************************************************
8
using System.Collections;
9
using NUnit.Framework.Constraints;
11
namespace NUnit.Framework
14
/// Helper class with static methods used to supply constraints
15
/// that operate on strings.
17
[Obsolete("Use Is class for string constraints")]
23
/// Returns a ConstraintExpression, which will apply
24
/// the following constraint to all members of a collection,
25
/// succeeding if all of them succeed.
27
[Obsolete("Use Is.All")]
28
public static ConstraintExpression All
30
get { return new ConstraintExpression().All; }
38
/// Returns a constraint that succeeds if the actual
39
/// value contains the substring supplied as an argument.
41
[Obsolete("Use Is.StringContaining")]
42
public static SubstringConstraint Contains(string expected)
44
return new SubstringConstraint(expected);
49
#region DoesNotContain
52
/// Returns a constraint that fails if the actual
53
/// value contains the substring supplied as an argument.
55
[Obsolete("Use Is.Not.StringContaining")]
56
public static SubstringConstraint DoesNotContain(string expected)
58
return new ConstraintExpression().Not.ContainsSubstring(expected);
66
/// Returns a constraint that succeeds if the actual
67
/// value starts with the substring supplied as an argument.
69
[Obsolete("Use Is.StringStarting")]
70
public static StartsWithConstraint StartsWith(string expected)
72
return new StartsWithConstraint(expected);
77
#region DoesNotStartWith
80
/// Returns a constraint that fails if the actual
81
/// value starts with the substring supplied as an argument.
83
public static StartsWithConstraint DoesNotStartWith(string expected)
85
return new ConstraintExpression().Not.StartsWith(expected);
93
/// Returns a constraint that succeeds if the actual
94
/// value ends with the substring supplied as an argument.
96
[Obsolete("Use Is.StringEnding")]
97
public static EndsWithConstraint EndsWith(string expected)
99
return new EndsWithConstraint(expected);
104
#region DoesNotEndWith
107
/// Returns a constraint that fails if the actual
108
/// value ends with the substring supplied as an argument.
110
public static EndsWithConstraint DoesNotEndWith(string expected)
112
return new ConstraintExpression().Not.EndsWith(expected);
120
/// Returns a constraint that succeeds if the actual
121
/// value matches the Regex pattern supplied as an argument.
123
[Obsolete("Use Is.StringMatching")]
124
public static RegexConstraint Matches(string pattern)
126
return new RegexConstraint(pattern);
134
/// Returns a constraint that fails if the actual
135
/// value matches the pattern supplied as an argument.
138
public static RegexConstraint DoesNotMatch(string pattern)
140
return new ConstraintExpression().Not.Matches(pattern);