//--- Methods --- /// <summary> /// Set up an expectation from a chain of parameters. /// </summary> /// <remarks> /// <see cref="IMockInvokeExpectationParameter"/> is meant to be used as a fluent interface to set up parameter qualifications for the expecation. /// </remarks> /// <returns>A new expectation configuration instance.</returns> public IMockInvokeExpectationParameter Expect() { var expectation = new AutoMockInvokeExpectation(_baseUri, _index++); _expectations.Add(expectation); return(expectation); }
void MockPlug.IMockInvokee.Invoke(Plug plug, string verb, XUri uri, DreamMessage request, Result <DreamMessage> response) { lock (this) { if (_failed) { _log.DebugFormat("we've already failed, no point checking more expectations"); response.Return(DreamMessage.InternalError()); return; } _log.DebugFormat("{0}={1}", verb, uri); XDoc requestDoc = request.HasDocument ? request.ToDocument() : null; if (_expectations.Count == _current) { _log.DebugFormat("excess"); ExcessInterception excess = new ExcessInterception(); _excess.Add(excess); ; response.Return(excess.Call(verb, uri, requestDoc)); return; } AutoMockInvokeExpectation expectation = _expectations[_current]; expectation.Call(verb, uri, request); if (!expectation.Verify()) { AddFailure(_expectations[_current].VerificationFailure); _log.DebugFormat("got failure, setting reset event ({0})", _current); _failed = true; _resetEvent.Set(); response.Return(DreamMessage.BadRequest("expectation failure")); return; } _current++; _log.DebugFormat("expected"); if (_expectations.Count == _current) { _log.DebugFormat("setting reset event"); _resetEvent.Set(); } response.Return(expectation.GetResponse()); } }
/// <summary> /// Create an expecation delegated to a callback. /// </summary> /// <param name="autoInvokeDelegate">Callback.</param> public void Expect(MockAutoInvokeDelegate autoInvokeDelegate) { AutoMockInvokeExpectation expectation = new AutoMockInvokeExpectation(autoInvokeDelegate); _expectations.Add(expectation); }
//--- Methods --- /// <summary> /// Set up an expectation from a chain of parameters. /// </summary> /// <remarks> /// <see cref="IMockInvokeExpectationParameter"/> is meant to be used as a fluent interface to set up parameter qualifications for the expecation. /// </remarks> /// <returns>A new expectation configuration instance.</returns> public IMockInvokeExpectationParameter Expect() { var expectation = new AutoMockInvokeExpectation(_baseUri, _index++); _expectations.Add(expectation); return expectation; }
/// <summary> /// Create an expecation delegated to a callback. /// </summary> /// <param name="autoInvokeDelegate">Callback.</param> public void Expect(MockAutoInvokeDelegate autoInvokeDelegate) { AutoMockInvokeExpectation expectation = new AutoMockInvokeExpectation(autoInvokeDelegate); _expectations.Add(expectation); }