internal static SequenceSetup SetupSequence(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 SequenceSetup(expression, propGet, new Expression[0]); var targetMock = GetTargetMock(((MemberExpression)expression.Body).Expression, mock); targetMock.Setups.Add(setup); return(setup); } else { var(obj, method, args) = expression.GetCallInfo(mock); var setup = new SequenceSetup(expression, method, args); var targetMock = GetTargetMock(obj, mock); targetMock.Setups.Add(setup); return(setup); } }
internal static SetupSequencePhrase SetupSequence(Mock mock, LambdaExpression expression) { var(obj, method, args) = expression.GetCallInfo(mock); var setup = new SequenceSetup(expression, method, args); var targetMock = GetTargetMock(obj, mock); targetMock.Setups.Add(setup); return(new SetupSequencePhrase(setup)); }