/// <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(); }
private Task <HttpResponseMessage> SendAsync(HttpCall setup, MockHttpRequestContext requestContext, CancellationToken cancellationToken) { ((InvokedHttpRequestCollection)InvokedRequests).Add(new InvokedHttpRequest(setup, requestContext.Request)); return(setup.SendAsync(requestContext, cancellationToken)); }
public HttpCallTests() { _sut = new HttpCall(); _sut.SetResponse(new ResponseFuncStrategy((_, __) => Task.FromResult(new HttpResponseMessage()))); }
public InvokedHttpRequest(HttpCall setup, HttpRequestMessage request) { Setup = setup ?? throw new ArgumentNullException(nameof(setup)); Request = request ?? throw new ArgumentNullException(nameof(request)); }