public SetDiagnosticSettingCommandTests() { insightsDiagnosticsOperationsMock = new Mock<IServiceDiagnosticSettingsOperations>(); insightsManagementClientMock = new Mock<InsightsManagementClient>(); commandRuntimeMock = new Mock<ICommandRuntime>(); cmdlet = new SetAzureRmDiagnosticSettingCommand() { CommandRuntime = commandRuntimeMock.Object, InsightsManagementClient = insightsManagementClientMock.Object }; response = new ServiceDiagnosticSettingsGetResponse { RequestId = Guid.NewGuid().ToString(), StatusCode = HttpStatusCode.OK, Properties = new ServiceDiagnosticSettings { StorageAccountId = storageAccountId, Logs = new List<LogSettings> { new LogSettings { Category = "TestCategory1", Enabled = true }, new LogSettings { Category = "TestCategory2", Enabled = false } }, Metrics = new List<MetricSettings> { new MetricSettings { TimeGrain = TimeSpan.FromMinutes(1), Enabled = false }, new MetricSettings { TimeGrain = TimeSpan.FromHours(1), Enabled = true } } } }; insightsDiagnosticsOperationsMock.Setup(f => f.GetAsync(It.IsAny<string>())) .Returns(Task.FromResult<ServiceDiagnosticSettingsGetResponse>(response)) .Callback((string resourceId) => { this.calledResourceId = resourceId; }); insightsDiagnosticsOperationsMock.Setup(f => f.PutAsync(It.IsAny<string>(), It.IsAny<ServiceDiagnosticSettingsPutParameters>())) .Returns(Task.FromResult<EmptyResponse>(new EmptyResponse())) .Callback((string resourceId, ServiceDiagnosticSettingsPutParameters putParameters) => { this.calledResourceId = resourceId; this.calledPutParameters = putParameters; }); insightsManagementClientMock.SetupGet(f => f.ServiceDiagnosticSettingsOperations).Returns(this.insightsDiagnosticsOperationsMock.Object); }
public SetDiagnosticSettingCommandTests(Xunit.Abstractions.ITestOutputHelper output) { //ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output)); insightsDiagnosticsOperationsMock = new Mock<IServiceDiagnosticSettingsOperations>(); insightsManagementClientMock = new Mock<InsightsManagementClient>(); commandRuntimeMock = new Mock<ICommandRuntime>(); cmdlet = new SetAzureRmDiagnosticSettingCommand() { CommandRuntime = commandRuntimeMock.Object, InsightsManagementClient = insightsManagementClientMock.Object }; request = new ServiceDiagnosticSettingsResource { StorageAccountId = storageAccountId, Logs = new List<LogSettings> { new LogSettings { Category = "TestCategory1", Enabled = true }, new LogSettings { Category = "TestCategory2", Enabled = false } }, Metrics = new List<MetricSettings> { new MetricSettings { TimeGrain = TimeSpan.FromMinutes(1), Enabled = false }, new MetricSettings { TimeGrain = TimeSpan.FromHours(1), Enabled = true } } }; insightsDiagnosticsOperationsMock.Setup(f => f.GetAsync(It.IsAny<string>(), It.IsAny<CancellationToken>())) .Returns(Task.FromResult<ServiceDiagnosticSettingsResource>(request)) .Callback((string resourceId) => { this.calledResourceId = resourceId; }); Rest.Azure.AzureOperationResponse<ServiceDiagnosticSettingsResource> response = new AzureOperationResponse<ServiceDiagnosticSettingsResource> { Body = request }; insightsDiagnosticsOperationsMock.Setup(f => f.CreateOrUpdateWithHttpMessagesAsync(It.IsAny<string>(), It.IsAny<ServiceDiagnosticSettingsCreateOrUpdateParameters>(), It.IsAny<Dictionary<string,List<string>>>(), It.IsAny<CancellationToken>())) .Returns(Task.FromResult<Rest.Azure.AzureOperationResponse<ServiceDiagnosticSettingsResource>>(response)) .Callback((string resourceId, ServiceDiagnosticSettingsCreateOrUpdateParameters putParameters, Dictionary<string,List<string>> headers) => { this.calledResourceId = resourceId; this.calledPutParameters = putParameters; }); insightsManagementClientMock.SetupGet(f => f.ServiceDiagnosticSettings).Returns(this.insightsDiagnosticsOperationsMock.Object); }