单元测试连接到云存储

本文关键字:存储 连接 单元测试 | 更新日期: 2023-09-27 18:16:47

我正在使用c#,我想对连接到云存储的基本参数进行单元测试。我不知道如何为它写一个有意义的测试。

谁能告诉我我应该写什么只是为了测试连接?

[TestMethod()]
[DeploymentItem("SkinImagingCloudConnectionLayer.dll")]
public void SetUpConnectionTest()
{
    CloudConnection_Accessor.SetUpConnection();
    Assert.Inconclusive("A method that does not return a value cannot be verified.");
}
private static void SetUpConnection()
{
    // Use the local storage account.
    //cloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
    cloudStorageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=*****;AccountKey=LBQ8k1myLKUKry03******************Itid+9BpV45GHAIWQ==");
    #region Select (or create) a Blob Container... it's like a Folder!
    // Create the blob client, which provides
    // authenticated access to the Blob service.
    blobClient = cloudStorageAccount.CreateCloudBlobClient();
    // Get the container reference.
    blobContainer = blobClient.GetContainerReference("cp300");
    // Create the container if it does not exist.
    blobContainer.CreateIfNotExist();
    // Set permissions on the container.
    containerPermissions = new BlobContainerPermissions();
    // This sample sets the container to have public blobs. Your application
    // needs may be different. See the documentation for BlobContainerPermissions
    // for more information about blob container permissions.
    containerPermissions.PublicAccess = BlobContainerPublicAccessType.Blob;
    blobContainer.SetPermissions(containerPermissions);
    #endregion
}

单元测试连接到云存储

为了说清楚。您正在创建一个集成测试—而不是单元测试:0)