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));
        }
Пример #2
0
        public async Task GetIfExist()
        {
            #region Snippet:Managing_FileShares_GetFileShareIFExists
            FileShareCollection fileShareCollection = fileService.GetFileShares();
            FileShare           fileShare           = await fileShareCollection.GetIfExistsAsync("foo");

            if (fileShare != null)
            {
                Console.WriteLine(fileShare.Id.Name);
            }
            if (await fileShareCollection.ExistsAsync("bar"))
            {
                Console.WriteLine("file share 'bar' exists");
            }
            #endregion
        }