Ejemplo n.º 1
0
        public static async Task <string> ExtractDownloadedFolder(string downloadFileUrl, string jwtToken)
        {
            //Mock api fullfillment process takes more time to upload file for the cancellation product and tests are intermittently failing,therefore we have added delay 'Thread.Sleep()' to avoid intermittent failure in the pipe.
            Thread.Sleep(20000);
            string tempFilePath = Path.Combine(Path.GetTempPath(), EssConfig.ExchangeSetFileName);
            var    response     = await FssApiClient.GetFileDownloadAsync(downloadFileUrl, accessToken : jwtToken);

            Assert.AreEqual(200, (int)response.StatusCode, $"Incorrect status code File Download api returned {response.StatusCode} for the url {downloadFileUrl}, instead of the expected 200.");

            Stream stream = await response.Content.ReadAsStreamAsync();

            using (FileStream outputFileStream = new FileStream(tempFilePath, FileMode.Create))
            {
                stream.CopyTo(outputFileStream);
            }

            WriteToConsole($"Temp file {tempFilePath} has been created to download file contents.");

            string zipPath     = tempFilePath;
            string extractPath = Path.GetTempPath() + RenameFolder(tempFilePath);

            ZipFile.ExtractToDirectory(zipPath, extractPath);

            return(extractPath);
        }
Ejemplo n.º 2
0
        public static async Task <string> CheckBatchIsCommitted(string batchStatusUri, string jwtToken)
        {
            string batchStatus = "";
            var    startTime   = DateTime.UtcNow;

            while (DateTime.UtcNow - startTime < TimeSpan.FromMinutes(Config.BatchCommitWaitTime))
            {
                await Task.Delay(5000);

                var batchStatusResponse = await FssApiClient.GetBatchStatusAsync(batchStatusUri, jwtToken);

                Assert.AreEqual(200, (int)batchStatusResponse.StatusCode, $"Incorrect status code is returned {batchStatusResponse.StatusCode}, instead of the expected status 200 for url {batchStatusUri}.");

                var batchStatusResponseObj = JsonConvert.DeserializeObject <ResponseBatchStatusModel>(await batchStatusResponse.Content.ReadAsStringAsync());
                batchStatus = batchStatusResponseObj.Status;

                if (batchStatus.Equals("Committed"))
                {
                    break;
                }
            }

            return(batchStatus);
        }
Ejemplo n.º 3
0
 static FssBatchHelper()
 {
     FssApiClient = new FssApiClient();
     EssConfig    = new TestConfiguration();
 }