public void GetBlob_PageBlob_GetsBlockBlobType() { var containerName = _util.GenerateSampleContainerName(_runId); var initialBlobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreatePageBlob(containerName, initialBlobName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var response = client.GetBlob(containerName, initialBlobName); Assert.AreEqual(Communications.Common.BlobType.Page, response.BlobType); }
public void GetBlob_ExistingBlobByValidStartAndEndRange_DownloadBlobRangeOnly() { var expectedContent = "Expected blob content"; var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName, content: expectedContent); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var response = client.GetBlob(containerName, blobName, range: new BlobRange(2, 6)); var data = response.GetDataBytes(); Assert.AreEqual(expectedContent.Substring(2, 5), Encoding.UTF8.GetString(data)); }
public void GetBlob_NonCopiedBlob_GetsCorrectCopyProperties() { var containerName = _util.GenerateSampleContainerName(_runId); var initialBlobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, initialBlobName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var response = client.GetBlob(containerName, initialBlobName); _util.AssertBlobCopyPropertiesMatch(containerName, initialBlobName, response); }
public void GetBlob_ExistingBlob_DownloadsBlobStream() { const string expectedContent = "Expected blob content"; var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName, content: expectedContent); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var response = client.GetBlob(containerName, blobName); byte[] data; using (var stream = response.GetDataStream()) { using (var ms = new MemoryStream()) { stream.CopyTo(ms); data = ms.ToArray(); } } Assert.AreEqual(expectedContent, Encoding.UTF8.GetString(data)); }
public void GetBlob_NonExistentBlob_ThrowsBlobDoesNotExistException() { var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); client.GetBlob(containerName, blobName); // expects exception }
public void GetBlob_LeasedBlobGivenInvalidLease_ThrowsArgumentException() { var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName); _util.LeaseBlob(containerName, blobName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); client.GetBlob(containerName, blobName, null, leaseId: InvalidLeaseId); // Throws exception }
public void GetBlob_LeasedBlobGivenIncorrectLease_ThrowsLeaseIdMismatchWithBlobOperationAzureException() { var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName); _util.LeaseBlob(containerName, blobName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); client.GetBlob(containerName, blobName, null, leaseId: GetGuidString()); // Throws exception }
public void GetBlob_LeasedBlobWithoutLeaseSpecified_GetsBlobWithoutException() { var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName); _util.LeaseBlob(containerName, blobName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var blob = client.GetBlob(containerName, blobName); blob = null; client = null; // no exception thrown }
public void GetBlob_ExistingBlob_DownloadsBlobBytes() { const string expectedContent = "Expected blob content"; var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName, content: expectedContent); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var response = client.GetBlob(containerName, blobName); var data = response.GetDataBytes(); Assert.AreEqual(expectedContent, Encoding.UTF8.GetString(data)); }
public void GetBlob_LeasedBlobWithCorrectLeaseSpecified_GetsBlobWithoutException() { var containerName = GenerateSampleContainerName(); var blobName = GenerateSampleBlobName(); CreateContainer(containerName); CreateBlockBlob(containerName, blobName); var leaseId = LeaseBlob(containerName, blobName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); client.GetBlob(containerName, blobName, null, leaseId); // no exception thrown }