Exemplo n.º 1
0
        public async Task Batch_Homogenous_Delete()
        {
            await using TestScenario scenario = Scenario();
            Uri[]           uris   = scenario.GetInvalidBlobUris(2);
            BlobBatchClient client = scenario.GetBlobBatchClient();

            using BlobBatch batch = client.CreateBatch();

            batch.DeleteBlob(uris[0]);
            InvalidOperationException ex = Assert.Throws <InvalidOperationException>(
                () => batch.SetBlobAccessTier(uris[1], AccessTier.Cool));

            batch.Dispose();

            StringAssert.Contains("already being used for Delete operations", ex.Message);
        }
Exemplo n.º 2
0
        public async Task SetBlobAccessTier_Error()
        {
            // Arrange
            BlobServiceClient service = GetServiceClient_SharedKey();
            BlobServiceClient invalidServiceClient = InstrumentClient(new BlobServiceClient(
                                                                          GetServiceClient_SharedKey().Uri,
                                                                          GetOptions()));
            BlobBatchClient blobBatchClient = invalidServiceClient.GetBlobBatchClient();

            using BlobBatch batch = blobBatchClient.CreateBatch();
            batch.SetBlobAccessTier(new Uri("https://account.blob.core.windows.net/container/blob"), AccessTier.Archive);

            // Act
            await TestHelper.AssertExpectedExceptionAsync <RequestFailedException>(
                blobBatchClient.SubmitBatchAsync(batch),
                e => Assert.AreEqual(BlobErrorCode.NoAuthenticationInformation.ToString(), e.ErrorCode));
        }
Exemplo n.º 3
0
        public async Task SetBlobAccessTier_Version()
        {
            await using TestScenario scenario = Scenario();
            BlockBlobClient[] blobs = await scenario.CreateBlockBlobsAsync(1);

            Response <BlobInfo> setMetadataResponse = await blobs[0].SetMetadataAsync(BuildMetadata());

            blobs[0] = blobs[0].WithVersion(setMetadataResponse.Value.VersionId);

            BlobBatchClient client = scenario.GetBlobBatchClient();

            using BlobBatch batch = client.CreateBatch();
            Response[] responses = new Response[]
            {
                batch.SetBlobAccessTier(blobs[0].Uri, AccessTier.Cool),
            };
            Response response = await client.SubmitBatchAsync(batch);

            scenario.AssertStatus(202, response);
            scenario.AssertStatus(200, responses);
            await scenario.AssertTiers(AccessTier.Cool, blobs);
        }
Exemplo n.º 4
0
        public async Task SetBlobAccessTier_Snapshot()
        {
            await using TestScenario scenario = Scenario();
            BlockBlobClient[] blobs = await scenario.CreateBlockBlobsAsync(1);

            Response <BlobSnapshotInfo> blobSnapshotResponse = await blobs[0].CreateSnapshotAsync();

            blobs[0] = blobs[0].WithSnapshot(blobSnapshotResponse.Value.Snapshot);

            BlobBatchClient client = scenario.GetBlobBatchClient();

            using BlobBatch batch = client.CreateBatch();
            Response[] responses = new Response[]
            {
                batch.SetBlobAccessTier(blobs[0].Uri, AccessTier.Cool),
            };
            Response response = await client.SubmitBatchAsync(batch);

            scenario.AssertStatus(202, response);
            scenario.AssertStatus(200, responses);
            await scenario.AssertTiers(AccessTier.Cool, blobs);
        }