public void Test_SetQuota() { HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath(); using (MockContext context = MockContext.Start(this.GetType())) { var quotaExtensionClient = QuotaTestUtilities.GetAzureQuotaExtensionAPIClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var newQuotaLimit = new QuotaProperties() { Limit = new LimitObject() { Value = 1005 }, Name = new ResourceName() { Value = resourceName } }; var quotaRequest = quotaExtensionClient.Quota.BeginCreateOrUpdate(resourceName, scope, newQuotaLimit); // 202 response has no response body Assert.True(quotaRequest == null); } }
public void Test_GetQuota() { HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath(); using (MockContext context = MockContext.Start(this.GetType())) { var quotaExtensionClient = QuotaTestUtilities.GetAzureQuotaExtensionAPIClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var quota = quotaExtensionClient.Quota.Get(resourceName, scope); Assert.Equal(quota.Name, resourceName, ignoreCase: true); } }
public void Test_GetQuotaRequest() { HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath(); string requestId = "2c3d0274-10b6-44ae-82ed-a0647057d696"; using (MockContext context = MockContext.Start(this.GetType())) { var quotaExtensionClient = QuotaTestUtilities.GetAzureQuotaExtensionAPIClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var quotaRequests = quotaExtensionClient.QuotaRequestStatus.Get(requestId, scope); Assert.Equal(quotaRequests.Name, requestId, ignoreCase: true); } }
public void Test_ListQuotaRequest() { HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath(); using (MockContext context = MockContext.Start(this.GetType())) { var quotaExtensionClient = QuotaTestUtilities.GetAzureQuotaExtensionAPIClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var quotaRequests = quotaExtensionClient.QuotaRequestStatus.List(scope); Assert.True(quotaRequests.All(x => string.Equals(x.Type, "Microsoft.Quota/QuotaRequests", StringComparison.OrdinalIgnoreCase) )); } }
public void Test_ListQuotaRequestWithFilter() { HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath(); int top = 5; string filter = "provisioningState eq 'Failed'"; using (MockContext context = MockContext.Start(this.GetType())) { var quotaExtensionClient = QuotaTestUtilities.GetAzureQuotaExtensionAPIClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var quotaRequests = quotaExtensionClient.QuotaRequestStatus.List(scope, filter: filter, top: top); Assert.True(quotaRequests.Count() == top); Assert.True(quotaRequests.All(x => string.Equals(x.ProvisioningState, "Failed", StringComparison.OrdinalIgnoreCase) )); } }
public void Test_SetQuotaInvalidResourceName() { HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath(); try { using (MockContext context = MockContext.Start(this.GetType())) { var quotaExtensionClient = QuotaTestUtilities.GetAzureQuotaExtensionAPIClient( context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var newQuotaLimit = new QuotaProperties() { Limit = new LimitObject() { Value = 1005 }, Name = new ResourceName() { Value = "PublicIPAddress" } }; var quotaRequest = quotaExtensionClient.Quota.BeginCreateOrUpdate( "PublicIPAddress", scope, newQuotaLimit); Assert.True(quotaRequest == null); } } catch (ExceptionResponseException ex) { Assert.True(ex.Response.StatusCode == HttpStatusCode.BadRequest); Assert.Contains("InvalidResourceName", ex.ToString()); } }