/// <summary> /// Arranges a mocked property. /// </summary> /// <typeparam name="TResult">The type of value returned from the mocked property.</typeparam> /// <param name="matchExpression">The match expression that describes where /// this <see cref="PropertyArrangement{TResult}"/> will be applied.</param> /// <returns>A new <see cref="PropertyArrangement{TResult}"/> used to apply property behavior.</returns> public PropertyArrangement <TResult> ArrangeProperty <TResult>(Expression <Func <TMock, TResult> > matchExpression) { var arrangement = new PropertyArrangement <TResult>(matchExpression); arrangements.Add(arrangement); return(arrangement); }
public IArrangement ArrangePropertyInternal <TProperty>(LambdaExpression matchExpression) { var matchInfo = matchExpression.ToMatchInfo(); var arrangement = arrangements.InvokeLocked( c => (from i in arrangements let a = i as PropertyArrangement <TProperty> where a != null && a.Matches(matchInfo) select a).FirstOrDefault()); if (arrangement == null) { arrangement = new PropertyArrangement <TProperty>(matchExpression); arrangements.Add(arrangement); } return(arrangement); }