简体   繁体   English

从 AZURE 检索 URL 的单元测试

[英]Unit test for retrive URL from AZURE

I want to upload an image to azure and to retrieve the absolut url .我想将图像上传到 azure 并检索绝对 url 。

And my method is something like that我的方法是这样的

    CloudStorageAccount storageacc = CloudStorageAccount.Parse(storageConnectionString);

CloudBlobClient blobClient = storageacc.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("myblob");
container.CreateIfNotExists();

CloudBlockBlob blockBlob = container.GetBlockBlobReference("images");

using (var filestream = System.IO.File.OpenRead(@"C:\\Users\\John\\Desktop\\11173.jpg"))
{
    blockBlob.UploadFromStream(filestream);
}
return blob.AbsoluteURI

Can suggest me how can I write a good code in XUNIT ?可以建议我如何在 XUNIT 中编写好的代码吗? Thank you !谢谢 !

I'm not sure that you should test this part in unit tests, because unit tests uses in isolation of all external processes like database or object storage.我不确定您是否应该在单元测试中测试这部分,因为单元测试与所有外部进程(如数据库或对象存储)隔离使用。 Maybe it would be better to test it in integration tests as a part of full business process with all dependencies也许最好在集成测试中对其进行测试,作为具有所有依赖项的完整业务流程的一部分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM