Beispiel #1
0
        public async Task CloudFileDirectoryWithFilesDeleteAsync()
        {
            CloudFileClient client = GenerateCloudFileClient();
            string          name   = GetRandomShareName();
            CloudFileShare  share  = client.GetShareReference(name);

            try
            {
                await share.CreateAsync();

                if (await CloudFileDirectorySetupAsync(share))
                {
                    CloudFileDirectory dir1    = share.GetRootDirectoryReference().GetDirectoryReference("TopDir1/MidDir1/EndDir1");
                    CloudFile          file1   = dir1.GetFileReference("EndFile1");
                    OperationContext   context = new OperationContext();
                    await TestHelper.ExpectedExceptionAsync(
                        async() => await dir1.DeleteAsync(null, null, context),
                        context,
                        "Delete a non-empty directory",
                        HttpStatusCode.Conflict);

                    await file1.DeleteAsync();

                    await dir1.DeleteAsync();

                    Assert.IsFalse(await file1.ExistsAsync());
                    Assert.IsFalse(await dir1.ExistsAsync());
                }
            }
            finally
            {
                share.DeleteAsync().Wait();
            }
        }
Beispiel #2
0
        public async Task CloudFileDirectoryCreateIfNotExistsAsync()
        {
            CloudFileShare share = GetRandomShareReference();
            await share.CreateAsync();

            try
            {
                CloudFileDirectory directory = share.GetRootDirectoryReference().GetDirectoryReference("directory1");
                Assert.IsTrue(await directory.CreateIfNotExistsAsync());
                Assert.IsFalse(await directory.CreateIfNotExistsAsync());
                await directory.DeleteAsync();

                Assert.IsTrue(await directory.CreateIfNotExistsAsync());
            }
            finally
            {
                share.DeleteAsync().Wait();
            }
        }
Beispiel #3
0
        public async Task CloudFileDirectoryApisInvalidApisInShareSnapshotAsync()
        {
            CloudFileShare share = GetRandomShareReference();
            await share.CreateAsync();

            CloudFileShare snapshot = await share.SnapshotAsync();

            CloudFileDirectory dir = snapshot.GetRootDirectoryReference().GetDirectoryReference("dir1");

            try
            {
                dir.CreateAsync().Wait();
                Assert.Fail("API should fail in a snapshot");
            }
            catch (InvalidOperationException e)
            {
                Assert.AreEqual(SR.CannotModifyShareSnapshot, e.Message);
            }
            try
            {
                dir.DeleteAsync().Wait();
                Assert.Fail("API should fail in a snapshot");
            }
            catch (InvalidOperationException e)
            {
                Assert.AreEqual(SR.CannotModifyShareSnapshot, e.Message);
            }
            try
            {
                dir.SetMetadataAsync(null, null, null).Wait();
                Assert.Fail("API should fail in a snapshot");
            }
            catch (InvalidOperationException e)
            {
                Assert.AreEqual(SR.CannotModifyShareSnapshot, e.Message);
            }

            snapshot.DeleteAsync().Wait();
            share.DeleteAsync().Wait();
        }