public async Task OpenReadIfExistsAsyncReturnsNullOnNoBlob() { var target = new CloudBlobWrapper(_cloudBlobMock.Object); _cloudBlobMock .Setup(cb => cb.OpenReadAsync(It.IsAny <AccessCondition>(), It.IsAny <BlobRequestOptions>(), It.IsAny <OperationContext>())) .ThrowsAsync(CreateBlobNotFoundException()) .Verifiable(); var returnedStream = await target.OpenReadIfExistsAsync(); _cloudBlobMock.VerifyAll(); Assert.Null(returnedStream); }
public async Task OpenReadIfExistsAsyncPassesThroughExceptions() { var target = new CloudBlobWrapper(_cloudBlobMock.Object); var exception = new TestException(); _cloudBlobMock .Setup(cb => cb.OpenReadAsync(It.IsAny <AccessCondition>(), It.IsAny <BlobRequestOptions>(), It.IsAny <OperationContext>())) .ThrowsAsync(exception) .Verifiable(); var thrownException = await Assert.ThrowsAsync <TestException>(() => target.OpenReadIfExistsAsync()); _cloudBlobMock.VerifyAll(); Assert.Same(exception, thrownException); }
public async Task OpenReadIfExistsAsyncReturnsStream() { var target = new CloudBlobWrapper(_cloudBlobMock.Object); using (var stream = new MemoryStream()) { _cloudBlobMock .Setup(cb => cb.OpenReadAsync(It.IsAny <AccessCondition>(), It.IsAny <BlobRequestOptions>(), It.IsAny <OperationContext>())) .ReturnsAsync(stream) .Verifiable(); var returnedStream = await target.OpenReadIfExistsAsync(); _cloudBlobMock.VerifyAll(); Assert.Same(stream, returnedStream); } }