Exemple #1
0
        public Task <SalesCatalogueProductResponse> DownloadSalesCatalogueResponse(string scsResponseUri, string batchId, string correlationId)
        {
            return(logger.LogStartEndAndElapsedTimeAsync(EventIds.DownloadSalesCatalogueResponseDataStart,
                                                         EventIds.DownloadSalesCatalogueResponseDataCompleted,
                                                         "Sales catalogue response download from blob for scsResponseUri:{scsResponseUri} and BatchId:{batchId} and _X-Correlation-ID:{correlationId}",
                                                         async() => {
                string storageAccountConnectionString = scsStorageService.GetStorageAccountConnectionString();
                CloudBlockBlob cloudBlockBlob = azureBlobStorageClient.GetCloudBlockBlobByUri(scsResponseUri, storageAccountConnectionString);

                var responseFile = await azureBlobStorageClient.DownloadTextAsync(cloudBlockBlob);
                SalesCatalogueProductResponse salesCatalogueProductResponse = JsonConvert.DeserializeObject <SalesCatalogueProductResponse>(responseFile);

                return salesCatalogueProductResponse;
            },
                                                         scsResponseUri, batchId, correlationId));
        }
Exemple #2
0
        public async Task WhenCallDownloadSalesCatalogueResponse_ThenReturnsSalesCatalogueProductResponse()
        {
            string scsResponseUri = "https://essTest/myCallback?secret=test&po=1234";
            string fakeBatchId    = "7b4cdf10-adfa-4ed6-b2fe-d1543d8b7272";
            string storageAccountConnectionString = "DefaultEndpointsProtocol = https; AccountName = testessdevstorage2; AccountKey =testaccountkey; EndpointSuffix = core.windows.net";

            A.CallTo(() => fakeScsStorageService.GetStorageAccountConnectionString("StorageAccountName", "StorageAccountKey")).Returns(storageAccountConnectionString);

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

            A.CallTo(() => fakeAzureBlobStorageClient.DownloadTextAsync(A <CloudBlockBlob> .Ignored)).Returns("{\"Products\":[{\"productName\":\"DE5NOBRK\",\"editionNumber\":1,\"updateNumbers\":[0,1],\"fileSize\":200}],\"ProductCounts\":{\"RequestedProductCount\":1,\"ReturnedProductCount\":1,\"RequestedProductsAlreadyUpToDateCount\":0,\"RequestedProductsNotReturned\":[]}}");
            A.CallTo(() => fakeSmallExchangeSetInstance.GetInstanceNumber(1)).Returns(3);
            var response = await azureBlobStorageService.DownloadSalesCatalogueResponse(scsResponseUri, fakeBatchId, null);

            Assert.IsInstanceOf <SalesCatalogueProductResponse>(response);
            Assert.AreEqual("DE5NOBRK", response.Products[0].ProductName);
            Assert.AreEqual(1, response.Products[0].EditionNumber);
            Assert.AreEqual(0, response.Products[0].UpdateNumbers[0].Value);
        }