public void Exists()
        {
            var containerName = Guid.NewGuid().ToString().Replace("-", string.Empty);
            var container     = new BinaryContainer(CloudStorageAccount.DevelopmentStorageAccount, containerName);

            Assert.IsFalse(container.Exists());
            container.EnsureExist();
            Assert.IsTrue(container.Exists());
            container.DeleteIfExist();
            Assert.IsFalse(container.Exists());
        }
        public void EnsureExists()
        {
            var containerName = Guid.NewGuid().ToString().Replace("-", string.Empty);
            var container     = new BinaryContainer(CloudStorageAccount.DevelopmentStorageAccount, containerName);

            container.EnsureExist();

            var client       = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudBlobClient();
            var containerRef = client.GetContainerReference(containerName.ToLowerInvariant());

            Assert.IsNotNull(containerRef);
        }
        public void EnsureExistsPublic()
        {
            var containerName = Guid.NewGuid().ToString().Replace("-", string.Empty);
            var container     = new BinaryContainer(CloudStorageAccount.DevelopmentStorageAccount, containerName);

            container.EnsureExist(true);

            var client       = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudBlobClient();
            var containerRef = client.GetContainerReference(containerName.ToLowerInvariant());

            Assert.IsNotNull(containerRef);
            var permissions = containerRef.GetPermissions();

            Assert.IsNotNull(permissions);
            Assert.AreEqual <BlobContainerPublicAccessType>(BlobContainerPublicAccessType.Container, permissions.PublicAccess);
        }
        public void GetBytesExtension()
        {
            var    bytes  = new byte[256];
            Random random = new Random();

            random.NextBytes(bytes);
            var containerName = Guid.NewGuid().ToString().Replace("-", string.Empty);
            var container     = new BinaryContainer(CloudStorageAccount.DevelopmentStorageAccount, containerName);

            container.EnsureExist();

            var id       = string.Format("{0}.jpeg", Guid.NewGuid());
            var uri      = container.Save(id, bytes, "na");
            var returned = container.GetBytes(id);

            Assert.IsTrue(bytes.ContentEquals(returned));
        }
Exemplo n.º 5
0
        public void SaveWithTimeOut()
        {
            var    bytes  = new byte[256];
            Random random = new Random();

            random.NextBytes(bytes);
            var containerName = "aslasdasdkdjh";
            var container     = new BinaryContainer(CloudStorageAccount.DevelopmentStorageAccount, containerName);

            container.EnsureExist();

            var id       = Guid.NewGuid().ToString();
            var uri      = container.Save(id, bytes, "na", new TimeSpan(0, 1, 0));
            var returned = container.GetBytes(id);

            Assert.IsTrue(bytes.ContentEquals(returned));
        }
        public void GetStream()
        {
            var    bytes  = new byte[256];
            Random random = new Random();

            random.NextBytes(bytes);
            var containerName = Guid.NewGuid().ToString().Replace("-", string.Empty);
            var container     = new BinaryContainer(CloudStorageAccount.DevelopmentStorageAccount, containerName);

            container.EnsureExist();

            var id  = Guid.NewGuid().ToString();
            var uri = container.Save(id, bytes, "na");

            using (var stream = container.GetStream(id) as MemoryStream)
            {
                var returned = stream.ToArray();
                Assert.IsTrue(bytes.ContentEquals(returned));
            }
        }