Example #1
0
        public async Task DownloadTextReturnsNullIfBlobDoesntExist()
        {
            var target = new CloudBlobWrapper(_cloudBlobMock.Object);

            _cloudBlobMock
            .Setup(cb => cb.DownloadTextAsync())
            .ThrowsAsync(CreateBlobNotFoundException())
            .Verifiable();

            var result = await target.DownloadTextIfExistsAsync();

            Assert.Null(result);
        }
Example #2
0
        public async Task DownloadTextPassesThroughExceptions()
        {
            var target    = new CloudBlobWrapper(_cloudBlobMock.Object);
            var exception = new TestException();

            _cloudBlobMock
            .Setup(cb => cb.DownloadTextAsync())
            .ThrowsAsync(exception)
            .Verifiable();

            var thrownException = await Assert.ThrowsAsync <TestException>(() => target.DownloadTextIfExistsAsync());

            Assert.Same(exception, thrownException);
        }
Example #3
0
        public async Task DownloadsText()
        {
            var          target = new CloudBlobWrapper(_cloudBlobMock.Object);
            const string text   = "sometext";

            _cloudBlobMock
            .Setup(cb => cb.DownloadTextAsync())
            .ReturnsAsync(text)
            .Verifiable();

            var result = await target.DownloadTextIfExistsAsync();

            _cloudBlobMock.VerifyAll();
            Assert.Equal(text, result);
        }