Example #1
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();
            }
        }
Example #2
0
        public async Task CloudFileNonexistentRootDirectoryCreateIfNotExistsAsync()
        {
            CloudFileShare share = GetRandomShareReference();
            await share.DeleteIfExistsAsync();

            CloudFileDirectory rootDirectory = share.GetRootDirectoryReference();
            OperationContext   context       = new OperationContext();
            await TestHelper.ExpectedExceptionAsync(
                async() => await rootDirectory.CreateIfNotExistsAsync(null, context),
                context,
                "Calling CreateIfNotExistsAsync on a nonexistent root directory should have resulted in an error 404",
                HttpStatusCode.NotFound);
        }