/// <summary> /// Scenario test for breaking a lease. /// </summary> /// <param name="containerName">The name of the container.</param> /// <param name="blobName">The name of the blob, if any.</param> /// <param name="breakPeriod">The break period.</param> /// <param name="expectedRemainingTime">The expected remaining time.</param> /// <param name="expectedError">The error status code to expect.</param> /// <returns>The remaining lease time.</returns> public async Task <int> BreakLeaseScenarioTest(string containerName, string blobName, int?breakPeriod, int?expectedRemainingTime, HttpStatusCode?expectedError) { // Create and validate the web request HttpRequestMessage request = BlobTests.BreakLeaseRequest(BlobContext, containerName, blobName, breakPeriod, null); using (HttpResponseMessage response = await BlobTestUtils.GetResponse(request, BlobContext)) { int expectedTime = expectedRemainingTime ?? breakPeriod.Value; int errorMargin = 10; BlobTests.BreakLeaseResponse(response, expectedTime, errorMargin, expectedError); return(expectedError.HasValue ? 0 : BlobHttpResponseParsers.GetRemainingLeaseTime(response).Value); } }
/// <summary> /// Scenario test for breaking a lease. /// </summary> /// <param name="containerName">The name of the container.</param> /// <param name="blobName">The name of the blob, if any.</param> /// <param name="breakPeriod">The break period.</param> /// <param name="expectedRemainingTime">The expected remaining time.</param> /// <param name="expectedError">The error status code to expect.</param> /// <returns>The remaining lease time.</returns> public int BreakLeaseScenarioTest(string containerName, string blobName, int?breakPeriod, int?expectedRemainingTime, HttpStatusCode?expectedError) { // Create and validate the web request HttpWebRequest request = BlobTests.BreakLeaseRequest(BlobContext, containerName, blobName, breakPeriod, null); if (BlobContext.Credentials != null) { BlobTests.SignRequest(request, BlobContext); } using (HttpWebResponse response = BlobTestUtils.GetResponse(request, BlobContext)) { int expectedTime = expectedRemainingTime ?? breakPeriod.Value; int errorMargin = 10; BlobTests.BreakLeaseResponse(response, expectedTime, errorMargin, expectedError); return(expectedError.HasValue ? 0 : BlobHttpResponseParsers.GetRemainingLeaseTime(response).Value); } }