2011-12-05 114 views
0

我正在使用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 
} 
+1

連接的哪個方面是您要測試的?你想連接到真實的東西或存根? –

+0

我想表明程序和雲存儲本身之間存在連接 – user1081326

+0

SetUpConnection()應該做什麼?你可以測試什麼作爲它被稱爲成功的人工製品?此外,由於您正在使用2個接口,這實際上是一個集成測試。爲什麼你有Assert.Inclusive的陳述? 「連接存在」是什麼意思?它是開放的,在線的,可用的,在使用中......你是什麼意思? –

回答

0

只是爲了說清楚。您正在創建一個集成測試 - 而不是單元測試:o)