/// <summary> /// Creates a RequestInterceptor that does not contact the Batch Service on a Get NodeFile or a Get NodeFile Properties call. /// The interceptor must handle both request types since it's possible for one OM node file method to perform both REST APIs. /// </summary> /// <param name="fileName">The name of the file to put in the response body.</param> public static RequestInterceptor CreateFakGetFileAndPropertiesResponseInterceptor(string fileName) { RequestInterceptor interceptor = new RequestInterceptor((baseRequest) => { BatchRequest <ProxyModels.NodeFileGetParameters, ProxyModels.NodeFileGetResponse> fileRequest = baseRequest as BatchRequest <ProxyModels.NodeFileGetParameters, ProxyModels.NodeFileGetResponse>; if (fileRequest != null) { fileRequest.ServiceRequestFunc = (cancellationToken) => { ProxyModels.NodeFileGetResponse response = new ProxyModels.NodeFileGetResponse(); Task <ProxyModels.NodeFileGetResponse> task = Task.FromResult(response); return(task); }; } else { BatchRequest <ProxyModels.NodeFileGetPropertiesParameters, ProxyModels.NodeFileGetPropertiesResponse> propRequest = (BatchRequest <ProxyModels.NodeFileGetPropertiesParameters, ProxyModels.NodeFileGetPropertiesResponse>)baseRequest; propRequest.ServiceRequestFunc = (cancellationToken) => { ProxyModels.NodeFileGetPropertiesResponse response = BatchTestHelpers.CreateNodeFileGetPropertiesResponse(fileName); Task <ProxyModels.NodeFileGetPropertiesResponse> task = Task.FromResult(response); return(task); }; } }); return(interceptor); }
/// <summary> /// Builds a NodeFileGetPropertiesResponse object /// </summary> public static ProxyModels.NodeFileGetPropertiesResponse CreateNodeFileGetPropertiesResponse(string fileName) { ProxyModels.NodeFileGetPropertiesResponse response = new ProxyModels.NodeFileGetPropertiesResponse(); response.StatusCode = HttpStatusCode.OK; ProxyModels.NodeFile file = new ProxyModels.NodeFile(); file.Name = fileName; response.File = file; return(response); }
/// <summary> /// Builds a NodeFileGetPropertiesResponse object /// </summary> public static ProxyModels.NodeFileGetPropertiesResponse CreateNodeFileGetPropertiesResponse(string fileName) { ProxyModels.NodeFileGetPropertiesResponse response = new ProxyModels.NodeFileGetPropertiesResponse(); response.StatusCode = HttpStatusCode.OK; ProxyModels.NodeFile file = new ProxyModels.NodeFile(); file.Name = fileName; response.File = file; return response; }