/// <summary> /// Convert a context from a PSObject /// </summary> /// <param name="other"></param> public PSAzureContext(PSObject other) { if (other == null || other.Properties == null) { throw new ArgumentNullException(nameof(other)); } PSObject property; if (other.TryGetProperty(nameof(Account), out property)) { Account = new PSAzureRmAccount(property); } if (other.TryGetProperty(nameof(Environment), out property)) { Environment = new PSAzureEnvironment(property); } if (other.TryGetProperty(nameof(Subscription), out property)) { Subscription = new PSAzureSubscription(property); } if (other.TryGetProperty(nameof(Tenant), out property)) { Tenant = new PSAzureTenant(property); } VersionProfile = other.GetProperty <string>(nameof(VersionProfile)); this.PopulateExtensions(other); }
public void CanConvertValidPSAzureAccounts(string id, string type) { var oldAccount = new PSAzureRmAccount { Id = id, Type = type }; var account = (AzureAccount)oldAccount; Assert.Equal(oldAccount.Type, account.Type); Assert.Equal(oldAccount.Id, account.Id); }