public void LockAndWriteResource()
        {
            var azureBlobContainer = new TestAzureBlobContainer(
                CloudConfiguration.GetStorageAccount("DataConnectionString"),
                AzureBlobTestContainer);

            var objId = Guid.NewGuid().ToString();

            azureBlobContainer.Save(objId, "testText");

            var context = new PessimisticConcurrencyContext()
            {
                ObjectId = objId
            };

            try
            {
                azureBlobContainer.AcquireLock(context);
                azureBlobContainer.Save(context, "testTextUpdated");
            }
            finally
            {
                azureBlobContainer.ReleaseLock(context);
            }

            Assert.AreEqual("testTextUpdated", azureBlobContainer.Get(objId));
        }
        public void DeleteShouldRemoveTheBlob()
        {
            var objId = Guid.NewGuid().ToString();

            var azureBlobContainer = new TestAzureBlobContainer(
                CloudConfiguration.GetStorageAccount("DataConnectionString"),
                AzureBlobTestContainer);

            azureBlobContainer.Save(objId, "testText");

            Assert.IsNotNull(azureBlobContainer.Get(objId));

            azureBlobContainer.Delete(objId);

            Assert.IsNull(azureBlobContainer.Get(objId));
        }
Exemplo n.º 3
0
        public void OptimisticCreateNewBlob()
        {
            var azureBlobContainer = new TestAzureBlobContainer(
                CloudConfiguration.GetStorageAccount("DataConnectionString"),
                AzureBlobTestContainer);

            var objId = Guid.NewGuid().ToString();

            OptimisticConcurrencyContext context;
            var text = azureBlobContainer.Get(objId, out context);

            Assert.IsNull(text);
            Assert.AreEqual(context.ObjectId, objId);

            azureBlobContainer.Save(objId, "testText");

            text = azureBlobContainer.Get(objId, out context);

            Assert.IsNotNull(text);
            Assert.AreEqual(context.ObjectId, objId);
        }