/// <summary> /// Tests the typical POST request. /// </summary> /// <param name="parametersLine">The parameters line.</param> /// <param name="inputFileName">Name of the input file.</param> /// <param name="resultFileName">Name of the result file.</param> /// <param name="saveResultToStorage">If result should be saved to storage</param> /// <param name="invokeRequestFunc">The invoke request function that returns response length.</param> /// <param name="folder">The folder.</param> /// <param name="storage">The storage.</param> protected void TestRawPostRequest( string parametersLine, string inputFileName, string resultFileName, bool saveResultToStorage, PostRequestInvokerDelegate invokeRequestFunc, string folder = CloudTestFolder, string storage = DefaultStorage) { TestRequestInternal( parametersLine, null, resultFileName, saveResultToStorage, () => { using (var fs = File.OpenRead(Path.Combine(LocalTestFolderFullPath, inputFileName))) { var stream = invokeRequestFunc.Invoke(fs, saveResultToStorage ? $"{CloudTempFolder}/{resultFileName}" : null); return(stream); } }, (_, stream, refInfo) => { var referenceLength = refInfo.Size; CheckSizeDiff(referenceLength ?? 0, stream.Length); }, folder, storage); }
/// <summary> /// Obtains the length of the typical POST request response. /// </summary> /// <param name="inputPath">The input path.</param> /// <param name="requestInvoker">The request invoker.</param> /// <param name="outPath">The output path to save the result.</param> /// <param name="storage">The storage.</param> /// <returns></returns> private long ObtainPostResponseLength(string inputPath, string outPath, string storage, PostRequestInvokerDelegate requestInvoker) { var inputDownloadResponse = CadApi.DownloadFile(new DownloadFileRequest(inputPath, null, storage)); using (inputDownloadResponse) { using (var response = requestInvoker.Invoke(inputDownloadResponse, outPath)) { if (string.IsNullOrEmpty(outPath)) { Assert.NotNull(response); return(response.Length); } return(0); } } }