Beispiel #1
0
        public void CloudBlobContainerDeleteIfExistsAPM()
        {
            CloudBlobContainer container = GetRandomContainerReference();

            using (AutoResetEvent waitHandle = new AutoResetEvent(false))
            {
                IAsyncResult result = container.BeginDeleteIfExists(
                    ar => waitHandle.Set(),
                    null);
                waitHandle.WaitOne();
                Assert.IsFalse(container.EndDeleteIfExists(result));
                result = container.BeginCreate(
                    ar => waitHandle.Set(),
                    null);
                waitHandle.WaitOne();
                container.EndCreate(result);
                result = container.BeginDeleteIfExists(
                    ar => waitHandle.Set(),
                    null);
                waitHandle.WaitOne();
                Assert.IsTrue(container.EndDeleteIfExists(result));
                result = container.BeginDeleteIfExists(
                    ar => waitHandle.Set(),
                    null);
                waitHandle.WaitOne();
                Assert.IsFalse(container.EndDeleteIfExists(result));
            }
        }
Beispiel #2
0
        public void CloudBlobContainerCreateAPM()
        {
            CloudBlobContainer container = GetRandomContainerReference();

            using (AutoResetEvent waitHandle = new AutoResetEvent(false))
            {
                IAsyncResult result = container.BeginCreate(
                    ar => waitHandle.Set(),
                    null);
                waitHandle.WaitOne();
                container.EndCreate(result);
                result = container.BeginCreate(
                    ar => waitHandle.Set(),
                    null);
                waitHandle.WaitOne();
                TestHelper.ExpectedException(
                    () => container.EndCreate(result),
                    "Creating already exists container should fail",
                    HttpStatusCode.Conflict);
            }
            container.Delete();
        }