public GetAzureRmAutoscaleSettingTests(Xunit.Abstractions.ITestOutputHelper output) { ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output)); insightsAutoscaleOperationsMock = new Mock<IAutoscaleOperations>(); insightsManagementClientMock = new Mock<InsightsManagementClient>(); commandRuntimeMock = new Mock<ICommandRuntime>(); cmdlet = new GetAzureRmAutoscaleSettingCommand() { CommandRuntime = commandRuntimeMock.Object, InsightsManagementClient = insightsManagementClientMock.Object }; response = new AutoscaleSettingGetResponse() { RequestId = Guid.NewGuid().ToString(), StatusCode = HttpStatusCode.OK, Id = "", Location = "", Name = "", Properties = null, Tags = null, }; responseList = new AutoscaleSettingListResponse() { RequestId = Guid.NewGuid().ToString(), StatusCode = HttpStatusCode.OK, AutoscaleSettingResourceCollection = new AutoscaleSettingResourceCollection() { Value = new List<AutoscaleSettingResource>() { new AutoscaleSettingResource(){ Id = "", Location = "", Name = "", Properties = null, Tags = null, }, } } }; insightsAutoscaleOperationsMock.Setup(f => f.GetSettingAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>())) .Returns(Task.FromResult<AutoscaleSettingGetResponse>(response)) .Callback((string resourceGrp, string settingNm, CancellationToken t) => { resourceGroup = resourceGrp; settingName = settingNm; }); insightsAutoscaleOperationsMock.Setup(f => f.ListSettingsAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>())) .Returns(Task.FromResult<AutoscaleSettingListResponse>(responseList)) .Callback((string resourceGrp, string targetResourceId, CancellationToken t) => { resourceGroup = resourceGrp; targetResourceUri = targetResourceId; }); insightsManagementClientMock.SetupGet(f => f.AutoscaleOperations).Returns(this.insightsAutoscaleOperationsMock.Object); }
/// <summary> /// Initializes a new instance of the PSAutoscaleSetting class. /// </summary> /// <param name="autoscaleSettingSpec">The autoscale setting spec</param> public PSAutoscaleSetting(AutoscaleSettingGetResponse autoscaleSettingSpec) { // Keep the original values (types) in the base class base.Properties = autoscaleSettingSpec.Properties; base.Tags = autoscaleSettingSpec.Tags; this.Id = autoscaleSettingSpec.Id; this.Location = autoscaleSettingSpec.Location; this.Name = autoscaleSettingSpec.Name; this.Properties = new PSAutoscaleSettingProperty(autoscaleSettingSpec.Properties); this.Tags = new PSDictionaryElement(autoscaleSettingSpec.Tags); }
public void Autoscale_GetSetting() { var expectedAutoscaleSetting = CreateAutoscaleSetting(ResourceUri, "CpuPercentage", string.Empty); var expectedAutoscaleSettingGetResponse = new AutoscaleSettingGetResponse() { Id = ResourceUri, Location = "East US", Tags = new Dictionary<string, string> {{"tag1", "value1"}}, Name = expectedAutoscaleSetting.Name, Properties = expectedAutoscaleSetting, RequestId = "request id", StatusCode = HttpStatusCode.OK }; var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(expectedAutoscaleSettingGetResponse.ToJson()), }; var handler = new RecordedDelegatingHandler(response); InsightsManagementClient customClient = this.GetInsightsManagementClient(handler); AutoscaleSettingGetResponse actualResponse = customClient.AutoscaleOperations.GetSetting("resourceGroup1", "setting1"); AreEqual(expectedAutoscaleSettingGetResponse.Properties, actualResponse.Properties); }