private IExpectedCall DequeueLastEnqueuedExpectedCall() { IExpectedCall call = (IExpectedCall)expectedCalls[expectedCalls.Count - 1]; expectedCalls.RemoveAt(expectedCalls.Count - 1); return(call); }
/// <summary> /// Check the arguments of the last expected call. /// </summary> /// <param name="arguments">The arguments to be expected.</param> /// <remarks> /// Provide IExpectedValue objects for arguments requiring special handling. /// Provide a value for all arguments, including the out arguments. /// The values for the out arguments are however ignored (can be null or anything else). /// </remarks> public ManualMocker WithArguments(params object[] arguments) { IExpectedCall lastCall = DequeueLastEnqueuedExpectedCall(); EnqueueExpectedCall(new WithArgumentsCall(lastCall, arguments)); return(this); }
private IExpectedCall DequeueExpectedCall() { IExpectedCall call = (IExpectedCall)expectedCalls[0]; expectedCalls.RemoveAt(0); return(call); }
public bool MovePast(IExpectedCall expectedCall, IRecordedCalls recordedCalls) { if (recordedCalls.MoveToNext()) { return recordedCalls.Current.Matches(expectedCall); } return false; }
/// <summary> /// Implements IMocker. /// </summary> public void HandleCall(MockingProxy proxy, MockableCall call) { try { IExpectedCall expectedCall = DequeueExpectedCall(); expectedCall.Replay(call); } catch (ArgumentOutOfRangeException) { throw new ReplayMockException(call, "Call not expected."); } }
public bool MovePast(IExpectedCall expectedCall, IRecordedCalls recordedCalls) { expectedCalls.Add(expectedCall); var isWholeSequenceUpToNowMatched = false; isWholeSequenceUpToNowMatched = expectedCalls.IsSubsequenceOf(recordedCalls); return isWholeSequenceUpToNowMatched; }
/// <summary> /// Expect the last expected call to be repeated multiple times. /// </summary> /// <param name="timesToRepeat">Times the last expected call is expected to be called.</param> public ManualMocker RepeatTimes(int timesToRepeat) { IExpectedCall lastCall = DequeueLastEnqueuedExpectedCall(); for (int i = 0; i < timesToRepeat; i++) { EnqueueExpectedCall(lastCall); } return(this); }
public bool MovePast(IExpectedCall expectedCall, IRecordedCalls recordedCalls) { var isCurrentCallStillUnmatched = false; while (!isCurrentCallStillUnmatched && recordedCalls.MoveToNext()) { if (recordedCalls.Current.Matches(expectedCall)) { isCurrentCallStillUnmatched = true; } } return isCurrentCallStillUnmatched; }
internal bool MovePast(IExpectedCall expectedCall) { return callSequenceCursorStrategy.MovePast(expectedCall, recordedCalls); }
/// <summary> /// Constructs a WithArgumentsCall wrapper. /// </summary> /// <param name="innerCall">The IExpectedCall to wrap, for which the arguments should be checked.</param> /// <param name="arguments">The argument values to expect. Provide IExpectedValue instances for special checkings.</param> public WithArgumentsCall(IExpectedCall innerCall, object[] arguments) { this.innerCall = innerCall; this.arguments = arguments; }
public bool Matches(IExpectedCall currentExpectedCall) { return currentExpectedCall.Matches(Call, Target); }
/// <summary> /// Expect the given call. /// </summary> public ManualMocker ExpectCall(IExpectedCall expectedCall) { EnqueueExpectedCall(expectedCall); return this; }
private void EnqueueExpectedCall(IExpectedCall call) { expectedCalls.Add(call); }
public bool MovePast(IExpectedCall expectedCall, IRecordedCalls recordedCalls) { throw new NoSequenceAssignedException("No sequence set up for this mock. Please set up a valid sequence."); }
/// <summary> /// Expect the given call. /// </summary> public ManualMocker ExpectCall(IExpectedCall expectedCall) { EnqueueExpectedCall(expectedCall); return(this); }
public void Add(IExpectedCall expectedCall) { expectedCalls.Add(expectedCall); }