public async void GetBlobPropertiesAsync_ExistingBlob_GetsCorrectContentLength() { const string blobContents = "foo"; var expectedContentLength = Encoding.UTF8.GetByteCount(blobContents); var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName, content: blobContents); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.AreEqual(expectedContentLength, properties.ContentLength); }
public async void GetBlobPropertiesAsync_ExistingBlob_GetsCorrectContentType() { const string expectedContentType = "pigeon/feathers"; var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName, contentType: expectedContentType); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.AreEqual(expectedContentType, properties.ContentType); }
public async void GetBlobPropertiesAsync_LeasedBlobLeaseBroken_GetsLeaseStateBroken() { var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName); var lease = _util.LeaseBlob(containerName, blobName, TimeSpan.FromSeconds(15)); _util.BreakBlobLease(containerName, blobName, lease); IBlobServiceClient client = new BlobServiceClient(AccountSettings); Thread.Sleep(TimeSpan.FromSeconds(2)); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.AreEqual(LeaseState.Broken, properties.LeaseState); }
public async void GetBlobPropertiesAsync_LeasedBlob_GetsLeaseStatusLocked() { var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName); var lease = _util.LeaseBlob(containerName, blobName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.AreEqual(LeaseStatus.Locked, properties.LeaseStatus); }
public async void GetBlobPropertiesAsync_ExistingBlobWithSpecifiedContentLanguage_GetsCorrectContentLanguage() { const string expectedLanguage = "dour"; var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName, contentLanguage: expectedLanguage); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.AreEqual(expectedLanguage, properties.ContentLanguage); }
public async void GetBlobPropertiesAsync_EmptyBlobName_ThrowsArgumentNullException() { var containerName = GenerateSampleContainerName(); var blobName = string.Empty; IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); // exception thrown }
public async void GetBlobPropertiesAsync_ExistingBlobWithMetadata_GetsCorrectMetadata() { var metadata = new Dictionary<string, string>{ { "HeyHey", "We're the" }, { "GroundControl", "CallingMajor" } }; var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName, metadata); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.AreEqual(metadata, properties.Metadata); }
public async void GetBlobPropertiesAsync_ExistingBlobWithSpecifiedContentMD5_GetsCorrectContentMD5() { var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); var blobMD5 = _util.CreateBlockBlob(containerName, blobName) .Properties.ContentMD5; IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.AreEqual(blobMD5, properties.ContentMD5); }
public async void GetBlobPropertiesAsync_LeasedBlobLeaseBreaking_GetsLeaseStateBreaking() { var containerName = GenerateSampleContainerName(); var blobName = GenerateSampleBlobName(); CreateContainer(containerName); CreateBlockBlob(containerName, blobName); var lease = LeaseBlob(containerName, blobName, TimeSpan.FromSeconds(60)); BreakBlobLease(containerName, blobName, lease, 30); IBlobServiceClient client = new BlobServiceClient(AccountSettings); Thread.Sleep(TimeSpan.FromSeconds(16)); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.AreEqual(LeaseState.Breaking, properties.LeaseState); }
public async void GetBlobPropertiesAsync_NullBlobName_ThrowsArgumentNullException() { var containerName = _util.GenerateSampleContainerName(_runId); string blobName = null; IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); // exception thrown }
public async void GetBlobPropertiesAsync_UnleasedBlob_GetsLeaseStateAvailable() { var containerName = GenerateSampleContainerName(); var blobName = GenerateSampleBlobName(); CreateContainer(containerName); CreateBlockBlob(containerName, blobName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.AreEqual(LeaseState.Available, properties.LeaseState); }
public async void GetBlobPropertiesAsync_ExistingBlockBlob_GetsBlockBlobType() { var containerName = GenerateSampleContainerName(); var blobName = GenerateSampleBlobName(); CreateContainer(containerName); CreateBlockBlob(containerName, blobName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.AreEqual(Communications.BlobService.BlobType.Block, properties.BlobType); }
public async void GetBlobPropertiesAsync_ExistingBlobJustModified_GetsCorrectLastModified() { var containerName = GenerateSampleContainerName(); var blobName = GenerateSampleBlobName(); var createdAt = DateTime.Now; CreateContainer(containerName); CreateBlockBlob(containerName, blobName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); AssertDatesEqualWithTolerance(createdAt, properties.LastModified); }
public async void GetBlobPropertiesAsync_ExistingBlob_HasAnETag() { var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.IsNotNullOrEmpty(properties.ETag); }
public async void GetBlobPropertiesAsync_ExistingPageBlob_GetsPageBlobType() { var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreatePageBlob(containerName, blobName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.AreEqual(Communications.Common.BlobType.Page, properties.BlobType); }
public async void GetBlobPropertiesAsync_ExistingBlobModified_ETagPropertyChanges() { var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName); var initialProperties = _util.GetBlobProperties(containerName, blobName); _util.UpdateBlockBlob(containerName, blobName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var postChangeProperties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.AreNotEqual(initialProperties.ETag, postChangeProperties.ETag); }
public async void GetBlobPropertiesAsync_LeasedBlobWithFixedLeaseTime_GetsLeaseDurationFixed() { var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName); _util.LeaseBlob(containerName, blobName, TimeSpan.FromSeconds(20)); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.AreEqual(LeaseDuration.Fixed, properties.LeaseDuration); }
public async void GetBlobPropertiesAsync_ExistingBlobWithSpecifiedContentEncoding_GetsCorrectContentEncoding() { const string expectedEncoding = "with minimal distraction"; var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName, contentEncoding: expectedEncoding); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.AreEqual(expectedEncoding, properties.ContentEncoding); }
public async void GetBlobPropertiesAsync_LeasedBlobWithInfiniteLeaseTime_GetsLeaseDurationInfinite() { var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); _util.CreateBlockBlob(containerName, blobName); _util.LeaseBlob(containerName, blobName, null); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.AreEqual(LeaseDuration.Infinite, properties.LeaseDuration); }
public async void GetBlobPropertiesAsync_ExistingBlob_GetsCorrectDate() { var containerName = _util.GenerateSampleContainerName(_runId); var blobName = _util.GenerateSampleBlobName(_runId); _util.CreateContainer(containerName); var createdDate = DateTime.Now; _util.CreateBlockBlob(containerName, blobName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); _util.AssertDatesEqualWithTolerance(createdDate, properties.Date); }
public async void GetBlobPropertiesAsync_ExistingBlob_GetsProperties() { var containerName = GenerateSampleContainerName(); var blobName = GenerateSampleBlobName(); CreateContainer(containerName); CreateBlockBlob(containerName, blobName); IBlobServiceClient client = new BlobServiceClient(AccountSettings); var properties = await client.GetBlobPropertiesAsync(containerName, blobName); Assert.NotNull(properties); }