private Protocol.RequestInterceptor CreateOcpRangeConfirmationInterceptor <TRequest, TOptions, THeaders>( string expectedOcpRange, Func <TOptions, string> getOcpRange, InvocationTracker invocationTracker) where TRequest : Protocol.BatchRequest <TOptions, AzureOperationResponse <Stream, THeaders> > where TOptions : IOptions, new() where THeaders : IProtocolNodeFile, new() { return(new Protocol.RequestInterceptor(request => { if (request is TRequest getFileRequest) { getFileRequest.ServiceRequestFunc = t => { invocationTracker.Invoke(); Assert.Equal(expectedOcpRange, getOcpRange(getFileRequest.Options)); THeaders headers = new THeaders(); SetFakeProtocolNodeFileHeaders(headers); return Task.FromResult(new AzureOperationResponse <Stream, THeaders>() { Body = new MemoryStream(), Headers = headers }); }; } })); }