Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MockHttpHandler"/> class.
        /// </summary>
        public MockHttpHandler()
        {
            _setups         = new ConcurrentCollection <HttpCall>();
            InvokedRequests = new InvokedHttpRequestCollection(this);
            _items          = new Dictionary <Type, object>();
            _readOnlyItems  = new ReadOnlyDictionary <Type, object>(_items);

            _fallbackSetup = new HttpCall();
            Fallback       = new FallbackRequestSetupPhrase(_fallbackSetup);
            Reset();
        }
Example #2
0
 private Task <HttpResponseMessage> SendAsync(HttpCall setup, MockHttpRequestContext requestContext, CancellationToken cancellationToken)
 {
     ((InvokedHttpRequestCollection)InvokedRequests).Add(new InvokedHttpRequest(setup, requestContext.Request));
     return(setup.SendAsync(requestContext, cancellationToken));
 }
Example #3
0
 public HttpCallTests()
 {
     _sut = new HttpCall();
     _sut.SetResponse(new ResponseFuncStrategy((_, __) => Task.FromResult(new HttpResponseMessage())));
 }
Example #4
0
 public InvokedHttpRequest(HttpCall setup, HttpRequestMessage request)
 {
     Setup   = setup ?? throw new ArgumentNullException(nameof(setup));
     Request = request ?? throw new ArgumentNullException(nameof(request));
 }