public void PutBlockBlobAsList_MismatchedContentMD5_CreatesBlockBlobWithSpecifiedContentMD5()
        {
            var data = Encoding.UTF8.GetBytes("test content");
            var badData = Encoding.UTF8.GetBytes("bad content");
            var specifiedMismatchedContentMD5 = Convert.ToBase64String(MD5.Create().ComputeHash(badData));
            var containerName = GenerateSampleContainerName();
            var blobName = GenerateSampleBlobName();
            CreateContainer(containerName);
            IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings);

            client.PutBlockBlobAsList(4, containerName, blobName, data, contentMD5: specifiedMismatchedContentMD5);
            
            var properties = GetBlobProperties(containerName, blobName);
            AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
            Assert.AreEqual(specifiedMismatchedContentMD5, properties.ContentMD5);
        }
        public void PutBlockBlobAsList_SpecifiedCacheControl_CreatesBlockBlobWithSpecifiedCacheControl()
        {
            var data = Encoding.UTF8.GetBytes("test content");
            const string specifiedCacheControl = "foo";
            var containerName = GenerateSampleContainerName();
            var blobName = GenerateSampleBlobName();
            CreateContainer(containerName);
            IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings);

            client.PutBlockBlobAsList(4, containerName, blobName, data, cacheControl: specifiedCacheControl);
            
            var properties = GetBlobProperties(containerName, blobName);
            AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
            Assert.AreEqual(specifiedCacheControl, properties.CacheControl);
        }
        public void PutBlockBlobAsList_SpecifiedMetadata_CreatesBlockBlobWithSpecifiedMetadata()
        {
            var data = Encoding.UTF8.GetBytes("test content");
            var expectedMetadata = new Dictionary<string, string>
            {
                {"haikuLine1", "I dreamed I was in"},
                {"haikuLine2", "A long-running endless loop"},
                {"haikuLine3", "And then the next day"}
            };
            var containerName = GenerateSampleContainerName();
            var blobName = GenerateSampleBlobName();
            CreateContainer(containerName);
            IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings);

            client.PutBlockBlobAsList(4, containerName, blobName, data, metadata: expectedMetadata);
            
            var gottenMetadata = GetBlobMetadata(containerName, blobName);
            AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
            Assert.AreEqual(expectedMetadata, gottenMetadata);
        }
        public void PutBlockBlobAsList_BlockSizeLargerThanBlob_CreatesBlobWithoutError()
        {
            var expectedData = new byte[10];
            var containerName = GenerateSampleContainerName();
            var blobName = GenerateSampleBlobName();
            CreateContainer(containerName);
            IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings);

            client.PutBlockBlobAsList(expectedData.Length * 2, containerName, blobName, expectedData);

            AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
            AssertBlockBlobContainsData(containerName, blobName, expectedData);
        }
        public void PutBlockBlobAsList_LargerThanMaxSingleBlobSize_CreatesBlockBlobFromLatestBlocks()
        {
            var expectedData = new byte[MaxIntelligentSingleBlobUploadSizeOverride + 5];
            var containerName = GenerateSampleContainerName();
            var blobName = GenerateSampleBlobName();
            CreateContainer(containerName);
            IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings);

            client.PutBlockBlobAsList(MaxIntelligentSingleBlobUploadSizeOverride / 2, containerName, blobName, expectedData);

            AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
            AssertBlockBlobContainsData(containerName, blobName, expectedData);
        }
        public void PutBlockBlobAsList_OneByteAtATime_CreatesBlobOfCorrectLength()
        {
            const string dataPerBlock = "foo";
            var expectedData = Encoding.UTF8.GetBytes(string.Format("{0}{0}{0}", dataPerBlock));
            var containerName = GenerateSampleContainerName();
            var blobName = GenerateSampleBlobName();
            IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings);
            CreateContainer(containerName);

            client.PutBlockBlobAsList(1, containerName, blobName, expectedData);

            AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
            AssertBlockBlobContainsData(containerName, blobName, expectedData);
        }
        public void PutBlockBlobAsList_RequiredArgsOnly_CreatesBlockBlobFromLatestBlocks()
        {
            const string dataPerBlock = "foo";
            var expectedData = Encoding.UTF8.GetBytes(string.Format("{0}{0}{0}", dataPerBlock));
            var containerName = GenerateSampleContainerName();
            var blobName = GenerateSampleBlobName();
            IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings);
            CreateContainer(containerName);

            client.PutBlockBlobAsList(4, containerName, blobName, expectedData);

            AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
            AssertBlockBlobContainsData(containerName, blobName, expectedData);
        }
        public void PutBlockBlobAsList_SpecifiedContentLanguage_CreatesBlockBlobWithSpecifiedContentLanguage()
        {
            var data = Encoding.UTF8.GetBytes("test content");
            const string specifiedContentLanguage = "typeB";
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            IBlobServiceClientEx client = new BlobServiceClientEx(AccountSettings);

            client.PutBlockBlobAsList(4, containerName, blobName, data, contentLanguage: specifiedContentLanguage);

            var properties = _util.GetBlobProperties(containerName, blobName);
            _util.AssertBlobExists(containerName, blobName, BlobType.BlockBlob);
            Assert.AreEqual(specifiedContentLanguage, properties.ContentLanguage);
        }