public PSWorkspace(Workspace workspace, string resourceGroupName) { if (workspace == null) { throw new ArgumentNullException("workspace"); } this.ResourceGroupName = resourceGroupName; this.Name = workspace.Name; this.ResourceId = workspace.Id; this.Location = workspace.Location; this.Tags = workspace.Tags; if (workspace.Properties != null) { this.Sku = workspace.Properties.Sku != null ? workspace.Properties.Sku.Name : null; this.CustomerId = workspace.Properties.CustomerId; this.PortalUrl = workspace.Properties.PortalUrl; this.ProvisioningState = workspace.Properties.ProvisioningState; } }
/// <summary> /// Validates a workspace matches the expected properties. Throws assertion exceptions if validation fails. /// </summary> /// <param name="expected">Expected workspace</param> /// <param name="actual">Actual workspace</param> internal static void ValidateWorkspace(Workspace expected, Workspace actual) { Assert.NotNull(actual); Assert.NotNull(actual.Id); Assert.Equal(expected.Name, actual.Name); Assert.Equal(expected.Location, actual.Location); Assert.Equal(WorkspaceResourceType, actual.Type); if (expected.Tags != null) { Assert.Equal(expected.Tags.Count, actual.Tags.Count); foreach (var tag in expected.Tags) { Assert.True(actual.Tags.Contains(tag)); } } else { Assert.Null(actual.Tags); } Assert.NotNull(actual.Properties); var workspaceProperties = actual.Properties; Assert.Equal( expected.Properties != null && expected.Properties.Sku != null ? expected.Properties.Sku.Name : SkuNameEnum.Free, workspaceProperties.Sku.Name, StringComparer.OrdinalIgnoreCase); Assert.NotNull(workspaceProperties.PortalUrl); Assert.Equal("Succeeded", workspaceProperties.ProvisioningState, StringComparer.OrdinalIgnoreCase); Assert.Equal("Azure", workspaceProperties.Source, StringComparer.OrdinalIgnoreCase); Assert.NotNull(workspaceProperties.CustomerId); }