Exemplo n.º 1
0
        /// <summary>
        /// Test page blob writes, expecting success.
        /// </summary>
        /// <param name="testBlob">The page blob.</param>
        /// <param name="testAccessCondition">The access condition to use.</param>
        private void PageBlobWriteExpectSuccess(CloudPageBlob testBlob, AccessCondition testAccessCondition)
        {
            byte[] buffer = new byte[4 * 512];
            Random random = new Random();
            random.NextBytes(buffer);
            Stream pageStream = new MemoryStream(buffer);

            testBlob.ClearPages(512, 512, testAccessCondition, null /* options */);
            testBlob.WritePages(pageStream, 512, null, testAccessCondition, null /* options */);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Test page blob writes, expecting lease failure.
        /// </summary>
        /// <param name="testBlob">The page blob.</param>
        /// <param name="testAccessCondition">The failing access condition to use.</param>
        /// <param name="expectedErrorCode">The expected error code.</param>
        /// <param name="description">The reason why these calls should fail.</param>
        private void PageBlobWriteExpectLeaseFailure(CloudPageBlob testBlob, AccessCondition testAccessCondition, HttpStatusCode expectedStatusCode, string expectedErrorCode, string description)
        {
            byte[] buffer = new byte[4 * 1024];
            Random random = new Random();
            random.NextBytes(buffer);
            Stream pageStream = new MemoryStream(buffer);

            PageBlobCreateExpectLeaseFailure(testBlob, testAccessCondition, expectedStatusCode, expectedErrorCode, description);

            TestHelper.ExpectedException(
                () => testBlob.ClearPages(512, 512, testAccessCondition, null /* options */),
                description + " (Clear Pages)",
                expectedStatusCode,
                expectedErrorCode);
            TestHelper.ExpectedException(
                () => testBlob.WritePages(pageStream, 512, null, testAccessCondition, null /* options */),
                description + " (Write Pages)",
                expectedStatusCode,
                expectedErrorCode);
        }