Example #1
0
        public void CloudFileDirectoryCreateAndDeleteAPM()
        {
            CloudFileShare share = GetRandomShareReference();

            try
            {
                share.Create();
                using (AutoResetEvent waitHandle = new AutoResetEvent(false))
                {
                    CloudFileDirectory directory = share.GetRootDirectoryReference().GetDirectoryReference("directory1");
                    IAsyncResult       result    = directory.BeginCreate(
                        ar => waitHandle.Set(),
                        null);
                    waitHandle.WaitOne();
                    directory.EndCreate(result);
                    Assert.IsTrue(directory.Exists());
                    result = directory.BeginDelete(
                        ar => waitHandle.Set(),
                        null);
                    waitHandle.WaitOne();
                    directory.EndDelete(result);
                    Assert.IsFalse(directory.Exists());
                }
            }
            finally
            {
                share.Delete();
            }
        }
Example #2
0
        public void CloudFileDirectoryWithFilesDelete()
        {
            CloudFileClient client = GenerateCloudFileClient();
            string          name   = GetRandomShareName();
            CloudFileShare  share  = client.GetShareReference(name);

            try
            {
                share.Create();
                if (CloudFileDirectorySetup(share))
                {
                    CloudFileDirectory dir1  = share.GetRootDirectoryReference().GetDirectoryReference("TopDir1/MidDir1/EndDir1");
                    CloudFile          file1 = dir1.GetFileReference("EndFile1");
                    TestHelper.ExpectedException(
                        () => dir1.Delete(),
                        "Delete a non-empty directory",
                        HttpStatusCode.Conflict);

                    file1.Delete();
                    dir1.Delete();
                    Assert.IsFalse(file1.Exists());
                    Assert.IsFalse(dir1.Exists());
                }
            }
            finally
            {
                share.Delete();
            }
        }
Example #3
0
        public void CloudFileDirectoryCreateAndDelete()
        {
            CloudFileShare share = GetRandomShareReference();

            share.Create();

            try
            {
                CloudFileDirectory directory = share.GetRootDirectoryReference().GetDirectoryReference("directory1");
                directory.Create();
                Assert.IsTrue(directory.Exists());
                directory.Delete();
                Assert.IsFalse(directory.Exists());
            }
            finally
            {
                share.Delete();
            }
        }
Example #4
0
        public void CloudFileDirectoryWithFilesDeleteAPM()
        {
            CloudFileClient client = GenerateCloudFileClient();
            string          name   = GetRandomShareName();
            CloudFileShare  share  = client.GetShareReference(name);

            try
            {
                share.Create();
                if (CloudFileDirectorySetup(share))
                {
                    CloudFileDirectory dir1  = share.GetRootDirectoryReference().GetDirectoryReference("TopDir1/MidDir1/EndDir1");
                    CloudFile          file1 = dir1.GetFileReference("EndFile1");
                    using (AutoResetEvent waitHandle = new AutoResetEvent(false))
                    {
                        IAsyncResult result = dir1.BeginDelete(
                            ar => waitHandle.Set(),
                            null);
                        waitHandle.WaitOne();
                        TestHelper.ExpectedException(
                            () => dir1.EndDelete(result),
                            "Delete a non-empty directory",
                            HttpStatusCode.Conflict);

                        result = file1.BeginDelete(
                            ar => waitHandle.Set(),
                            null);
                        waitHandle.WaitOne();
                        file1.EndDelete(result);

                        result = dir1.BeginDelete(
                            ar => waitHandle.Set(),
                            null);
                        waitHandle.WaitOne();
                        dir1.EndDelete(result);
                    }

                    Assert.IsFalse(file1.Exists());
                    Assert.IsFalse(dir1.Exists());
                }
            }
            finally
            {
                share.Delete();
            }
        }