public void ParseResourceId_WithResourceGroupAsResource_ReturnsSubscriptionScope() { Guid subscriptionId = Guid.NewGuid(); (string scope, string relativeResourceId) = ResourceIdUtility.ParseResourceId( $"/subscriptions/{subscriptionId}/resourceGroups/test-what-if-rg"); Assert.Equal($"/subscriptions/{subscriptionId}", scope); Assert.Equal("resourceGroups/test-what-if-rg", relativeResourceId); }
public void ParseResourceId_WithResourceScopeLevelId_ReturnsResourceGroupScope() { Guid subscriptionId = Guid.NewGuid(); (string scope, string relativeResourceId) = ResourceIdUtility.ParseResourceId( $"/subscriptions/{subscriptionId}/resourceGroups/test-what-if-rg/providers/Microsoft.Sql/servers/TestServer"); Assert.Equal($"/subscriptions/{subscriptionId}/resourceGroups/test-what-if-rg", scope); Assert.Equal("Microsoft.Sql/servers/TestServer", relativeResourceId); }
public void ParseResourceId_WithSubscriptionLevelId_ReturnsSubscriptionScope() { Guid subscriptionId = Guid.NewGuid(); Guid roleAssignmentId = Guid.NewGuid(); (string scope, string relativeResourceId) = ResourceIdUtility.ParseResourceId( $"/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignment/{roleAssignmentId}"); Assert.Equal($"/subscriptions/{subscriptionId}", scope); Assert.Equal($"Microsoft.Authorization/roleAssignment/{roleAssignmentId}", relativeResourceId); }
public PSWhatIfChange(WhatIfChange whatIfChange) { this.whatIfChange = whatIfChange; (string scope, string relativeResourceId) = ResourceIdUtility.ParseResourceId(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()); }