コード例 #1
0
        protected Task <JsonResponse> MethodAsync(string url, string method, JsonDict body = null)
        {
            RequestAndResponse rar = _recording[_playbackIndex];

            RecordedRequest request = new RecordedRequest
            {
                Url    = url,
                Method = method,
                Body   = body
            };

            if (!request.Matches(rar.Request))
            {
                throw new Exception($"Actual request doesn't match recorded at index {_playbackIndex}");
            }

            _playbackIndex++;
            return(Task.FromResult(rar.Response));
        }
コード例 #2
0
 internal bool Matches(RecordedRequest other)
 {
     if (Url != other.Url || Method != other.Method)
     {
         return(false);
     }
     if (Body == null)
     {
         if (other.Body != null)
         {
             return(false);
         }
     }
     else
     {
         if (!Body.ShallowEquals(other.Body))
         {
             return(false);
         }
     }
     return(true);
 }