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); }
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); }
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); }