コード例 #1
0
        public void Setup()
        {
            _imageStream    = new FileStream("MockFiles/test.txt", FileMode.Open);
            _imageExtension = ".txt";

            Mock <IBlobClient> mockBlobClient = new Mock <IBlobClient>();

            mockBlobClient.Setup(c => c.Uri).Returns(new Uri(_blobClientBaseUri));
            mockBlobClient.Setup(c => c.DeleteBlobAsync(_existingBlobName)).ReturnsAsync(new SuccessResponse());
            mockBlobClient.Setup(c => c.DeleteBlobAsync(It.Is <string>(n => n != _existingBlobName))).ReturnsAsync(new ErrorResponse());

            Mock <IBlobClientFactory> mockBlobClientFactory = new Mock <IBlobClientFactory>();

            mockBlobClientFactory.Setup(m => m.CreateBlobClient()).ReturnsAsync(mockBlobClient.Object);

            _imageStorage = new AzureBlobImageStorage(mockBlobClientFactory.Object);
        }
コード例 #2
0
        private IImageStorage CreateImageStorage()
        {
            IImageStorage storage;

            if (Environment.IsProduction())
            {
                storage = new AzureBlobImageStorage(new AzureBlobClientFactory(Configuration.BlobStorageConnectionString, "images"));
            }
            else
            {
                string imageOutputPath = Path.Combine(Environment.WebRootPath, IMAGE_DIRECTORY_NAME);
                string imageBaseUri    = Path.Combine(Configuration.BaseUrl, STATIC_FILE_BASE_URI, IMAGE_DIRECTORY_NAME);

                storage = new LocalImageStorage(imageOutputPath, imageBaseUri);
            }

            return(storage);
        }