Open DanielSchiavini opened 7 years ago
@DanielSchiavini
We can't test TaskAttachmentService b/c it contains the real implementation for CRUD based blob storage in Azure. That's why TaskAttachementService is abstracted by ITaskAttachmentService. Any code that uses ITaskAttachementService should be tested/testable, but testing the service itself has no value.
The only thing I think could be testable by taking a look at the code is how we're building the path to the actual blob. That would be something I consider testable, but it's a very small piece and not really worth the effort.
That, OR we move the abstraction closer to the Azure API and abstract ONLY the Azure calls. For example, any code working with CloudBlobContainer and/or CloudBlockBlob would be abstracted away and our TaskAttachement service would use that abstraction in order to communicate with Azure.
So lines like this:
var blobContainer = CloudStorageAccount.Parse(_options.AzureStorage)
.CreateCloudBlobClient()
.GetContainerReference(ContainerName);
blobContainer.Uri.AbsoluteUri
blobContainer.GetBlockBlobReference
blockBlob.DeleteAsync()
container.CreateIfNotExistsAsync
container.GetBlockBlobReference
blockBlob.Properties.ContentType
blockBlob.UploadFromByteArrayAsync
blockBlob.Uri
would have to be abstracted. That's a lot of work, and as we use more and more Azure based functionality, this abstraction would only grow more unweildy... so again, I don't think there is value here.
Also, the Debug.WriteLine statements in this class should be deleted. We don't want that type of stuff in production code.
The code introduced in PR #1660 is not completely unit tested. We should at least introduce tests to TaskAttachmentService but preferably to the other classes involved in the PR.