public async Task CreateOrUpdate() { #region Snippet:Managing_FileShares_CreateFileShare FileShareCollection fileShareCollection = fileService.GetFileShares(); string fileShareName = "myFileShare"; FileShareData fileShareData = new FileShareData(); ArmOperation <FileShareResource> fileShareCreateOperation = await fileShareCollection.CreateOrUpdateAsync(WaitUntil.Started, fileShareName, fileShareData); FileShareResource fileShare = await fileShareCreateOperation.WaitForCompletionAsync(); #endregion }
public async Task CreateDeleteFileShare() { //create file share string fileShareName = Recording.GenerateAssetName("testfileshare"); FileShare share1 = (await _fileShareCollection.CreateOrUpdateAsync(true, fileShareName, new FileShareData())).Value; Assert.AreEqual(share1.Id.Name, fileShareName); //validate if created successfully FileShareData shareData = share1.Data; Assert.IsEmpty(shareData.Metadata); FileShare share2 = await _fileShareCollection.GetAsync(fileShareName); AssertFileShareEqual(share1, share2); Assert.IsTrue(await _fileShareCollection.ExistsAsync(fileShareName)); Assert.IsFalse(await _fileShareCollection.ExistsAsync(fileShareName + "1")); //delete file share await share1.DeleteAsync(true); //validate if deleted successfully FileShare fileShare3 = await _fileShareCollection.GetIfExistsAsync(fileShareName); Assert.IsNull(fileShare3); Assert.IsFalse(await _fileShareCollection.ExistsAsync(fileShareName)); }
public async Task CreateDeleteFileShare() { //create file share string fileShareName = Recording.GenerateAssetName("testfileshare"); FileShareResource share1 = (await _fileShareCollection.CreateOrUpdateAsync(WaitUntil.Completed, fileShareName, new FileShareData())).Value; Assert.AreEqual(share1.Id.Name, fileShareName); //validate if created successfully FileShareData shareData = share1.Data; Assert.IsEmpty(shareData.Metadata); FileShareResource share2 = await _fileShareCollection.GetAsync(fileShareName); AssertFileShareEqual(share1, share2); Assert.IsTrue(await _fileShareCollection.ExistsAsync(fileShareName)); Assert.IsFalse(await _fileShareCollection.ExistsAsync(fileShareName + "1")); //delete file share await share1.DeleteAsync(WaitUntil.Completed); //validate if deleted successfully var exception = Assert.ThrowsAsync <RequestFailedException>(async() => { await _fileShareCollection.GetAsync(fileShareName); }); Assert.AreEqual(404, exception.Status); Assert.IsFalse(await _fileShareCollection.ExistsAsync(fileShareName)); }