Exemplo n.º 1
0
        public async Task AllowsDefaultRequestOptionsToBeSet()
        {
            // Arrange
            var folderName = CoreConstants.Folders.ValidationFolderName;
            var fileName   = _prefixA;
            await _targetA.SaveFileAsync(
                folderName,
                fileName,
                new MemoryStream(new byte[1024 * 1024]),
                overwrite : false);

            var client = new CloudBlobClientWrapper(
                _fixture.ConnectionStringA,
                new BlobRequestOptions
            {
                MaximumExecutionTime = TimeSpan.FromMilliseconds(1),
            });
            var container   = client.GetContainerReference(folderName);
            var file        = container.GetBlobReference(fileName);
            var destination = new MemoryStream();

            // Act & Assert
            // This should throw due to timeout.
            var ex = await Assert.ThrowsAsync <StorageException>(() => file.DownloadToStreamAsync(destination));

            Assert.Contains("timeout", ex.Message);
        }
        public CloudBlobCoreFileStorageServiceIntegrationTests(BlobStorageFixture fixture)
        {
            _fixture = fixture ?? throw new ArgumentNullException(nameof(fixture));
            _testId  = Guid.NewGuid().ToString();
            _prefixA = $"{_fixture.PrefixA}/{_testId}";
            _prefixB = $"{_fixture.PrefixB}/{_testId}";

            _clientA = new CloudBlobClientWrapper(_fixture.ConnectionStringA, readAccessGeoRedundant: false);
            _clientB = new CloudBlobClientWrapper(_fixture.ConnectionStringB, readAccessGeoRedundant: false);

            _blobClientA = CloudStorageAccount.Parse(_fixture.ConnectionStringA).CreateCloudBlobClient();
            _blobClientB = CloudStorageAccount.Parse(_fixture.ConnectionStringB).CreateCloudBlobClient();

            _targetA = new CloudBlobCoreFileStorageService(_clientA, Mock.Of <IDiagnosticsService>());
            _targetB = new CloudBlobCoreFileStorageService(_clientB, Mock.Of <IDiagnosticsService>());
        }