コード例 #1
0
ファイル: MockPlug.cs プロジェクト: yurigorokhov/DReAM
        //--- 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);
        }
コード例 #2
0
ファイル: MockPlug.cs プロジェクト: yurigorokhov/DReAM
 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());
     }
 }
コード例 #3
0
ファイル: MockPlug.cs プロジェクト: maximmass/DReAM
 /// <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);
 }
コード例 #4
0
ファイル: MockPlug.cs プロジェクト: maximmass/DReAM
 //--- 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;
 }
コード例 #5
0
ファイル: MockPlug.cs プロジェクト: yurigorokhov/DReAM
        /// <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);
        }