Exemple #1
0
        private async Task <CloudBlobClient> ConnectAsync(CancellationToken cancellationToken)
        {
            if (_blobClient == null)
            {
                _blobClient = await _exportClientInitializer.GetAuthorizedClientAsync(_exportJobConfiguration, cancellationToken);
            }

            return(_blobClient);
        }
        public async Task GivenUnableToInitializeExportClient_WhenConnectAsync_ThenDestinationConnectionExceptionIsThrown()
        {
            string         message    = "Can't initialize client";
            HttpStatusCode statusCode = HttpStatusCode.BadRequest;

            _exportClientInitializer.GetAuthorizedClientAsync(Arg.Any <CancellationToken>()).Returns <CloudBlobClient>(x => throw new ExportClientInitializerException(message, statusCode));

            var exception = await Assert.ThrowsAsync <DestinationConnectionException>(() => _exportDestinationClient.ConnectAsync(CancellationToken.None));

            Assert.Contains(message, exception.Message);
            Assert.Equal(statusCode, exception.StatusCode);
        }