internal static SetupSequencePhrase <TResult> SetupSequence <TResult>(Mock mock, LambdaExpression expression) { if (expression.IsProperty()) { var prop = expression.ToPropertyInfo(); Guard.CanRead(prop); var propGet = prop.GetGetMethod(true); ThrowIfSetupExpressionInvolvesUnsupportedMember(expression, propGet); ThrowIfSetupMethodNotVisibleToProxyFactory(propGet); var setup = new SequenceMethodCall(mock, expression, propGet, new Expression[0]); var targetMock = GetTargetMock(((MemberExpression)expression.Body).Expression, mock); targetMock.Setups.Add(setup); return(new SetupSequencePhrase <TResult>(setup)); } else { var(obj, method, args) = expression.GetCallInfo(mock); var setup = new SequenceMethodCall(mock, expression, method, args); var targetMock = GetTargetMock(obj, mock); targetMock.Setups.Add(setup); return(new SetupSequencePhrase <TResult>(setup)); } }
internal static SetupSequencePhrase SetupSequence(Mock mock, LambdaExpression expression) { var(obj, method, args) = expression.GetCallInfo(mock); var setup = new SequenceMethodCall(mock, expression, method, args); var targetMock = GetTargetMock(obj, mock); targetMock.Setups.Add(setup); return(new SetupSequencePhrase(setup)); }