示例#1
0
 /// <summary>
 /// Register the predicate as a constraint for the current call.
 /// </summary>
 /// <param name="predicate">The predicate.</param>
 /// <returns>default(T)</returns>
 /// <example>
 /// Allow you to use code to create constraints
 /// <code>
 /// demo.AssertWasCalled(x => x.Bar(Arg{string}.Matches(a => a.StartsWith("b") &amp;&amp; a.Contains("ba"))));
 /// </code>
 /// </example>
 public static T Matches <TPredicate>(Predicate <TPredicate> predicate)
 {
     ArgManager.AddInArgument(Rhino.Mocks.Constraints.Is.Matching <TPredicate>(predicate));
     return(default(T));
 }
示例#2
0
 /// <summary>
 /// Define a complex constraint for this argument by passing several constraints
 /// combined with operators. (Use Is in simple cases.)
 /// Example: Arg&lt;string&gt;.Matches(Is.Equal("Hello") || Text.EndsWith("u"));
 /// </summary>
 /// <param name="constraint">Constraints using Is, Text and List</param>
 /// <returns>Dummy to satisfy the compiler</returns>
 public static T Matches(AbstractConstraint constraint)
 {
     ArgManager.AddInArgument(constraint);
     return(default(T));
 }
示例#3
0
 /// <summary>
 /// Register the predicate as a constraint for the current call.
 /// </summary>
 /// <param name="predicate">The predicate.</param>
 /// <returns>default(T)</returns>
 /// <example>
 /// Allow you to use code to create constraints
 /// <code>
 /// demo.AssertWasCalled(x => x.Bar(Arg{string}.Matches(a => a.StartsWith("b") &amp;&amp; a.Contains("ba"))));
 /// </code>
 /// </example>
 public static T Matches(Expression <Predicate <T> > predicate)
 {
     ArgManager.AddInArgument(new LambdaConstraint(predicate));
     return(default(T));
 }