public void OperationsTests_ListOperationsTest() { var handler = new RecordedDelegatingHandler(); var insightsClient = GetMonitorManagementClient(handler); var expResponse = new OperationListResult { Value = new List <Operation> { new Operation { Name = "Operation1", Display = new OperationDisplay { Operation = "Operation1", Provider = "microsoft.insights", Resource = "resource1" } }, new Operation { Name = "Operation2", Display = new OperationDisplay { Operation = "Operation2", Provider = "microsoft.insights", Resource = "resource2" } }, } }; var serializedObject = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(expResponse, insightsClient.SerializationSettings); var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(serializedObject) }; handler = new RecordedDelegatingHandler(expectedResponse); insightsClient = GetMonitorManagementClient(handler); OperationListResult operations = insightsClient.Operations.List(); Assert.Equal(2, operations.Value.Count); Assert.Equal("Operation1", operations.Value[0].Name); Assert.Equal("Operation1", operations.Value[0].Display.Operation); Assert.Equal("microsoft.insights", operations.Value[0].Display.Provider); Assert.Equal("resource1", operations.Value[0].Display.Resource); Assert.Equal("Operation2", operations.Value[1].Name); Assert.Equal("Operation2", operations.Value[1].Display.Operation); Assert.Equal("microsoft.insights", operations.Value[1].Display.Provider); Assert.Equal("resource2", operations.Value[1].Display.Resource); }
public async Task<Response<OperationListResult>> ListAsync(CancellationToken cancellationToken = default) { using var message = CreateListRequest(); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { OperationListResult value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = OperationListResult.DeserializeOperationListResult(document.RootElement); return Response.FromValue(value, message.Response); }
public void ListOperationsTest() { using (MockContext context = MockContext.Start(this.GetType())) { var insightsClient = GetMonitorManagementClient(context, handler); OperationListResult actual = insightsClient.Operations.List(); if (!this.IsRecording) { Check(insightsClient, actual); } } }
private static void Check( MonitorManagementClient insightsClient, OperationListResult operationListResult) { Assert.Equal(46, operationListResult.Value.Count); Assert.Equal("Microsoft.Insights/Operations/Read", operationListResult.Value[0].Name); Assert.Equal("Operations read", operationListResult.Value[0].Display.Operation); Assert.Equal("Microsoft Monitoring Insights", operationListResult.Value[0].Display.Provider); Assert.Equal("Operations", operationListResult.Value[0].Display.Resource); Assert.Equal("Microsoft.Insights/Webtests/Read", operationListResult.Value[45].Name); Assert.Equal("Webtest read", operationListResult.Value[45].Display.Operation); Assert.Equal("Microsoft Monitoring Insights", operationListResult.Value[45].Display.Provider); Assert.Equal("Web tests", operationListResult.Value[45].Display.Resource); }