/// <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") && 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)); }
/// <summary> /// Define a complex constraint for this argument by passing several constraints /// combined with operators. (Use Is in simple cases.) /// Example: Arg<string>.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)); }
/// <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") && a.Contains("ba")))); /// </code> /// </example> public static T Matches(Expression <Predicate <T> > predicate) { ArgManager.AddInArgument(new LambdaConstraint(predicate)); return(default(T)); }