public void Clear() { _currentMethodCall = null; _methodCallMatcherBuilder = MethodCallMatcherBuilder.Create(); _methodCallMatcher = null; _activeAssertion = null; }
protected override object Invoke(MethodInfo targetMethod, object[] args) { var methodCall = ProxyMethodCall.From(this, targetMethod, args); // TODO: CQS broken? // TODO: Move CurrentMethod & ArgumentMatchers back to context? var methodCallMatcher = ThreadLocalContext.SetCurrentMethodCall(methodCall); var activeAssertion = ThreadLocalContext.ConsumeAssertion(); if (activeAssertion != null) { activeAssertion.Check( new AssertionCall(this, methodCallMatcher.Method, methodCallMatcher.ArgumentMatchers), _methodCallHistory); } else { _methodCallHistory.AddCall(methodCall); var recordedCall = MethodSetups.FirstOrDefault(m => m.MatchesCall(methodCall)); if (recordedCall != null) { var result = recordedCall.InvokeBehaviour(methodCall.PassedArguments); // TODO: is this if needed? if (!object.ReferenceEquals(result, MethodSetup.NO_RESULT)) { return(result); } } } return(ReflectionUtils.CreateDefaultValue(targetMethod.ReturnType)); }
public MethodCallMatcher SetCurrentMethodCall(ProxyMethodCall methodCall) { _currentMethodCall = methodCall; _methodCallMatcher = _methodCallMatcherBuilder .WithMethodCall(methodCall) .Build(); _methodCallMatcherBuilder = MethodCallMatcherBuilder.Create(); return(_methodCallMatcher); }
internal void MarkMethodCallAsSetup(ProxyMethodCall call) { _methodCallHistory.RemoveCall(call); }
public bool MatchesCall(ProxyMethodCall call) { return(_methodCallMatcher.MatchesCall(call)); }
public void AddCall(ProxyMethodCall methodCall) => _receivedCalls.Add(methodCall);
public void RemoveCall(ProxyMethodCall methodCall) => _receivedCalls.Remove(methodCall);
public static MethodCallMatcher SetCurrentMethodCall(ProxyMethodCall methodCall) => _context.Value.SetCurrentMethodCall(methodCall);
public MethodCallMatcherBuilder WithMethodCall(ProxyMethodCall methodCall) { _methodCall = methodCall; return(this); }
public MissingArgumentMatcherPlaceholder(ProxyMethodCall methodCall, int argumentPosition) { this.InvalidMatcherUsageMessage = CreateMessage(methodCall, argumentPosition); }