public void Transaction_Id_Cannot_Be_Empty() { //Arrange var connection = new BlobConnection(Mock.Of <IStorageConnectionManager <CloudBlobClient> >()); //Act async Task <CloudBlobContainer> TestDelegate() => await connection.GetObjectAsync(Guid.Empty); //Assert Assert.That(TestDelegate, Throws.ArgumentException.With.Message.EqualTo("Id cannot be Empty")); }
public async Task Can_Get_Container() { //Arrange _mockManager.Setup(x => x.GetStorageClient()).Returns(Task.FromResult(_mockClient.Object)); _mockClient.Setup(x => x.GetContainerReference(It.IsAny <string>())).Returns(_mockContainer.Object); _mockContainer.Setup(x => x.CreateIfNotExistsAsync()).Returns(Task.FromResult(true)); var connection = new BlobConnection(_mockManager.Object); //Act var result = await connection.GetObjectAsync(Guid.NewGuid()); //Assert Assert.That(result, Is.EqualTo(_mockContainer.Object)); }
public void Exception_Thrown_In_Connection_Manager_Will_Bubble_Up() { //Arrange const string exceptionMessage = "Test Exception"; _mockManager.Setup(x => x.GetStorageClient()) .Throws(new Exception(exceptionMessage)); var connection = new BlobConnection(_mockManager.Object); //Act async Task <CloudBlobContainer> TestDelegate() => await connection.GetObjectAsync(Guid.NewGuid()); //Assert Assert.That(TestDelegate, Throws.Exception.With.Message.EqualTo(exceptionMessage)); }
public void Exception_Thrown_In_Cloud_Blob_Container_Will_Bubble_Up() { //Arrange const string exceptionMessage = "Test Exception"; _mockManager.Setup(x => x.GetStorageClient()).Returns(Task.FromResult(_mockClient.Object)); _mockClient.Setup(x => x.GetContainerReference(It.IsAny <string>())).Returns(_mockContainer.Object); _mockContainer.Setup(x => x.CreateIfNotExistsAsync()).Throws(new Exception(exceptionMessage)); var connection = new BlobConnection(_mockManager.Object); //Act async Task <CloudBlobContainer> TestDelegate() => await connection.GetObjectAsync(Guid.NewGuid()); //Assert Assert.That(TestDelegate, Throws.Exception.With.Message.EqualTo(exceptionMessage)); }