Exemplo n.º 1
0
        public async Task WhenGetNonCachedProductDataForFssIsCalled_ThenReturnProductNotFound()
        {
            string exchangeSetRootPath = @"C:\\HOME";

            A.CallTo(() => fakeAzureStorageService.GetStorageAccountConnectionString(A <string> .Ignored, A <string> .Ignored)).Returns(GetStorageAccountConnectionStringAndContainerName().Item1);
            A.CallTo(() => fakeAzureTableStorageClient.RetrieveFromTableStorageAsync <FssSearchResponseCache>(A <string> .Ignored, A <string> .Ignored, A <string> .Ignored, A <string> .Ignored)).Returns(GetResponseCache());
            A.CallTo(() => fakeAzureBlobStorageClient.GetCloudBlockBlob(A <string> .Ignored, A <string> .Ignored, A <string> .Ignored)).Returns(new CloudBlockBlob(new System.Uri("http://tempuri.org/blob")));
            A.CallTo(() => fakeFileSystemHelper.DownloadToFileAsync(A <CloudBlockBlob> .Ignored, A <string> .Ignored));

            var response = await fileShareServiceCache.GetNonCachedProductDataForFss(GetProductdetails(), GetSearchBatchResponse(), exchangeSetRootPath, GetScsResponseQueueMessage(), null, CancellationToken.None);

            Assert.AreEqual(0, response.Count);
        }
Exemplo n.º 2
0
        public async Task DeleteHistoricScsResponseFile(DirectoryInfo subDirectory, string storageAccountConnectionString, string containerName)
        {
            var    batchId             = subDirectory.Name;
            string scsResponseFileName = new DirectoryInfo(batchId).Name + ".json";

            CloudBlockBlob cloudBlockBlob = await azureBlobStorageClient.GetCloudBlockBlob(scsResponseFileName, storageAccountConnectionString, containerName);

            var response = await cloudBlockBlob.DeleteIfExistsAsync();

            if (response)
            {
                subDirectory.Delete(true);
                logger.LogInformation(EventIds.HistoricSCSResponseFileDeleted.ToEventId(), "SCS response json file {ScsResponseFileName} deleted successfully from the container.", scsResponseFileName);
            }
            else
            {
                logger.LogError(EventIds.HistoricSCSResponseFileNotFound.ToEventId(), "SCS response json file {ScsResponseFileName} not found in the container.", scsResponseFileName);
            }
        }
Exemplo n.º 3
0
        public async Task WhenCallStoreSaleCatalogueServiceResponseAsync_ThenReturnsTrue()
        {
            string batchId       = "7b4cdf10-adfa-4ed6-b2fe-d1543d8b7272";
            string containerName = "testContainer";
            string callBackUri   = "https://essTest/myCallback?secret=test&po=1234";
            string correlationId = "a6670458-9bbc-4b52-95a2-d1f50fe9e3ae";
            string storageAccountConnectionString = "DefaultEndpointsProtocol = https; AccountName = testessdevstorage2; AccountKey =testaccountkey; EndpointSuffix = core.windows.net";
            SalesCatalogueProductResponse salesCatalogueProductResponse = GetSalesCatalogueServiceResponse();
            CancellationToken             cancellationToken             = CancellationToken.None;

            A.CallTo(() => fakeScsStorageService.GetStorageAccountConnectionString(null, null)).Returns(storageAccountConnectionString);

            A.CallTo(() => fakeAzureBlobStorageClient.GetCloudBlockBlob(A <string> .Ignored, A <string> .Ignored, A <string> .Ignored)).Returns(new CloudBlockBlob(new System.Uri("http://tempuri.org/blob")));

            A.CallTo(() => fakeSmallExchangeSetInstance.GetInstanceNumber(1)).Returns(3);
            var response = await azureBlobStorageService.StoreSaleCatalogueServiceResponseAsync(containerName, batchId, salesCatalogueProductResponse, callBackUri, correlationId, cancellationToken, fakeExpiryDate);

            Assert.IsTrue(response);
        }
Exemplo n.º 4
0
        public async Task <bool> StoreSaleCatalogueServiceResponseAsync(string containerName, string batchId, SalesCatalogueProductResponse salesCatalogueResponse, string callBackUri, string correlationId, CancellationToken cancellationToken, string expiryDate)
        {
            string uploadFileName        = string.Concat(batchId, ".json");
            long   fileSize              = CommonHelper.GetFileSize(salesCatalogueResponse);
            var    fileSizeInMB          = CommonHelper.ConvertBytesToMegabytes(fileSize);
            var    instanceCountAndType  = GetInstanceCountBasedOnFileSize(fileSizeInMB);
            var    storageAccountWithKey = GetStorageAccountNameAndKeyBasedOnExchangeSetType(instanceCountAndType.Item2);

            string storageAccountConnectionString =
                scsStorageService.GetStorageAccountConnectionString(storageAccountWithKey.Item1, storageAccountWithKey.Item2);
            CloudBlockBlob cloudBlockBlob = await azureBlobStorageClient.GetCloudBlockBlob(uploadFileName, storageAccountConnectionString, containerName);

            cloudBlockBlob.Properties.ContentType = CONTENT_TYPE;

            await UploadSalesCatalogueServiceResponseToBlobAsync(cloudBlockBlob, salesCatalogueResponse);

            logger.LogInformation(EventIds.SCSResponseStoredToBlobStorage.ToEventId(), "Sales catalogue service response stored to blob storage with fileSizeInMB:{fileSizeInMB} for BatchId:{batchId} and _X-Correlation-ID:{CorrelationId} ", fileSizeInMB, batchId, correlationId);

            await AddQueueMessage(batchId, salesCatalogueResponse, callBackUri, correlationId, cloudBlockBlob, instanceCountAndType.Item1, storageAccountConnectionString, expiryDate);

            return(true);
        }