Esempio n. 1
0
        public async Task GetBlob_throwException_logError()
        {
            var listLogger      = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List);
            var mockBlobService = new Mock <IBlobStorageService>();

            mockBlobService.Setup(x => x.DownloadBlobAsync()).Throws(new Exception());
            var fnt = new GetBlob(mockBlobService.Object);

            await fnt.Run(null, listLogger);

            Assert.Contains("Error getting the blob", listLogger.Logs.Last());
        }
Esempio n. 2
0
        public async Task GetBlob_withData_logBlobContent()
        {
            var listLogger      = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List);
            var mockBlobService = new Mock <IBlobStorageService>();

            mockBlobService.Setup(x => x.DownloadBlobAsync()).Returns(Task.FromResult(GetMockBlob()));
            var fnt = new GetBlob(mockBlobService.Object);

            await fnt.Run(null, listLogger);

            Assert.Contains("Blob content: doc", listLogger.Logs[3]);
            Assert.Contains("blob content readed successfully", listLogger.Logs.Last());
        }
Esempio n. 3
0
        public async Task GetBlobsList_raiseException_returnExceptionResult()
        {
            var listLogger      = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List);
            var req             = TestFactory.CreateHttpRequest("mockRequest", "mockRequest");
            var mockBlobService = new Mock <IBlobStorageService>();

            mockBlobService.Setup(x => x.GetBlobsListAsync(It.IsAny <BlobContainerClient>())).Throws(new Exception());
            var fnt = new GetBlobsList(mockBlobService.Object);

            var response = await fnt.Run(req, listLogger);

            Assert.Contains("Error getting the blob list", listLogger.Logs.Last());
        }
Esempio n. 4
0
        public async Task GetBlobsList_withoutData_returnEmptyArray()
        {
            var listLogger      = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List);
            var req             = TestFactory.CreateHttpRequest("mockRequest", "mockRequest");
            var mockBlobService = GetMockBlobService(false);
            var fnt             = new GetBlobsList(mockBlobService);

            var response = (OkObjectResult)await fnt.Run(req, listLogger);

            string[] blobNames = response.Value as string[];
            Assert.NotNull(response);
            Assert.Equal(200, response.StatusCode);
            Assert.Empty(blobNames);
            Assert.Contains("There are no blobs in this container", listLogger.Logs[2]);
        }
Esempio n. 5
0
        public async Task GetBlobsList_withData_returnArrayOfBlobNames()
        {
            var listLogger      = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List);
            var req             = TestFactory.CreateHttpRequest("mockRequest", "mockRequest");
            var mockBlobService = GetMockBlobService(true);
            var fnt             = new GetBlobsList(mockBlobService);

            var response = (OkObjectResult)await fnt.Run(req, listLogger);

            string[] blobNames = response.Value as string[];
            Assert.NotNull(response);
            Assert.Equal(200, response.StatusCode);
            Assert.NotEmpty(blobNames);
            Assert.Equal(5, blobNames.Length);
            Assert.Contains("Blob list retieved with 5 blob names", listLogger.Logs[2]);
        }