public void SplitResourceId_ManagementGroupAsResource_ReturnsTenantScopeAndManagementGroupId() { const string resourceId = "/providers/Microsoft.Management/myManagementGroup"; (string scope, string relativeResourceId) = ResourceIdUtility.SplitResourceId(resourceId); Assert.Equal($"/", scope); Assert.Equal($"Microsoft.Management/myManagementGroup", relativeResourceId); }
public void SplitResourceId_ResourceGroupAsResource_ReturnsSubscriptionScopeAndResourceGroupId() { Guid subscriptionId = Guid.NewGuid(); string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/test-what-if-rg"; (string scope, string relativeResourceId) = ResourceIdUtility.SplitResourceId(resourceId); Assert.Equal($"/subscriptions/{subscriptionId}", scope); Assert.Equal("resourceGroups/test-what-if-rg", relativeResourceId); }
public void SplitResourceId_ResourceGroupLevelId_ReturnsResourceGroupScopeAndRelativeId() { Guid subscriptionId = Guid.NewGuid(); string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/test-what-if-rg/providers/Microsoft.Sql/servers/TestServer"; (string scope, string relativeResourceId) = ResourceIdUtility.SplitResourceId(resourceId); Assert.Equal($"/subscriptions/{subscriptionId}/resourceGroups/test-what-if-rg", scope); Assert.Equal("Microsoft.Sql/servers/TestServer", relativeResourceId); }
public void SplitResourceId_ManagementGroupLevelId_ReturnsManagementGroupScopeAndRelativeId() { Guid roleAssignmentId = Guid.NewGuid(); string resourceId = $"/providers/Microsoft.Management/ManagementGroups/myManagementGroup/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentId}"; (string scope, string relativeResourceId) = ResourceIdUtility.SplitResourceId(resourceId); Assert.Equal($"/providers/Microsoft.Management/ManagementGroups/myManagementGroup", scope); Assert.Equal($"Microsoft.Authorization/roleAssignments/{roleAssignmentId}", relativeResourceId); }
public void SplitResourceId_SubscriptionLevelId_ReturnsSubscriptionScopeAndRelativeId() { Guid subscriptionId = Guid.NewGuid(); Guid roleAssignmentId = Guid.NewGuid(); string resourceId = $"/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentId}"; (string scope, string relativeResourceId) = ResourceIdUtility.SplitResourceId(resourceId); Assert.Equal($"/subscriptions/{subscriptionId}", scope); Assert.Equal($"Microsoft.Authorization/roleAssignments/{roleAssignmentId}", relativeResourceId); }
public PSWhatIfChange(WhatIfChange whatIfChange) { this.whatIfChange = whatIfChange; (string scope, string relativeResourceId) = ResourceIdUtility.SplitResourceId(whatIfChange.ResourceId); this.Scope = scope; this.RelativeResourceId = relativeResourceId; this.apiVersion = new Lazy <string>(() => this.Before?["apiVersion"]?.Value <string>() ?? this.After?["apiVersion"]?.Value <string>()); this.before = new Lazy <JToken>(() => whatIfChange.Before.ToJToken()); this.after = new Lazy <JToken>(() => whatIfChange.After.ToJToken()); this.delta = new Lazy <IList <PSWhatIfPropertyChange> >(() => whatIfChange.Delta?.Select(pc => new PSWhatIfPropertyChange(pc)).ToList()); }