public async Task FileSharesCreateDeleteListTest() { // Create resource group string rgName = await CreateResourceGroupAsync(); string accountName = Recording.GenerateAssetName("sto"); // Create storage account StorageAccount account = await CreateStorageAccountAsync(rgName, accountName); VerifyAccountProperties(account, true); // implement case string shareName = Recording.GenerateAssetName("share"); FileShare fileShare = new FileShare(); Response <FileShare> share = await FileSharesClient.CreateAsync(rgName, accountName, shareName, fileShare); Assert.Null(share.Value.Metadata); share = await FileSharesClient.GetAsync(rgName, accountName, shareName); Assert.Null(share.Value.Metadata); string shareName2 = Recording.GenerateAssetName("share"); fileShare.Metadata = new Dictionary <string, string> { { "metadata1", "true" }, { "metadata2", "value2" } }; fileShare.ShareQuota = 500; Response <FileShare> share2 = await FileSharesClient.CreateAsync(rgName, accountName, shareName2, fileShare); Assert.AreEqual(2, share2.Value.Metadata.Count); Assert.AreEqual(fileShare.Metadata, share2.Value.Metadata); Assert.AreEqual(fileShare.ShareQuota, share2.Value.ShareQuota); share2 = await FileSharesClient.GetAsync(rgName, accountName, shareName2); Assert.AreEqual(2, share2.Value.Metadata.Count); Assert.AreEqual(fileShare.Metadata, share2.Value.Metadata); Assert.AreEqual(fileShare.ShareQuota, share2.Value.ShareQuota); //Delete share await FileSharesClient.DeleteAsync(rgName, accountName, shareName); AsyncPageable <FileShareItem> fileShares = FileSharesClient.ListAsync(rgName, accountName); Task <List <FileShareItem> > fileSharesList = fileShares.ToEnumerableAsync(); Assert.AreEqual(1, fileSharesList.Result.Count()); await FileSharesClient.DeleteAsync(rgName, accountName, shareName2); fileShares = FileSharesClient.ListAsync(rgName, accountName); fileSharesList = fileShares.ToEnumerableAsync(); Assert.AreEqual(0, fileSharesList.Result.Count()); //Delete not exist share, won't fail (return 204) await FileSharesClient.DeleteAsync(rgName, accountName, "notexistshare"); }
public async Task FileSharesUpdateGetTest() { // Create resource group var rgName = await CreateResourceGroupAsync(); string accountName = Recording.GenerateAssetName("sto"); // Create storage account Sku sku = new Sku(SkuName.StandardLRS); StorageAccountCreateParameters parameters = GetDefaultStorageAccountParameters(sku: sku, kind: Kind.StorageV2, location: "westeurope"); parameters.LargeFileSharesState = LargeFileSharesState.Enabled; await CreateStorageAccountAsync(rgName, accountName, parameters); // implement case string shareName = Recording.GenerateAssetName("share"); FileShare fileShare = new FileShare(); Response <FileShare> share = await FileSharesClient.CreateAsync(rgName, accountName, shareName, fileShare); Assert.Null(share.Value.Metadata); fileShare.Metadata = new Dictionary <string, string> { { "metadata1", "true" }, { "metadata2", "value2" } }; fileShare.ShareQuota = 5200; Response <FileShare> shareSet = await FileSharesClient.UpdateAsync(rgName, accountName, shareName, fileShare); Assert.NotNull(shareSet.Value.Metadata); Assert.AreEqual(fileShare.ShareQuota, shareSet.Value.ShareQuota); Assert.AreEqual(fileShare.Metadata, shareSet.Value.Metadata); Response <FileShare> shareGet = await FileSharesClient.GetAsync(rgName, accountName, shareName); Assert.NotNull(shareSet.Value.Metadata); Assert.AreEqual(fileShare.Metadata, shareGet.Value.Metadata); Assert.AreEqual(fileShare.ShareQuota, shareGet.Value.ShareQuota); }