Repository navigation
Expand file tree
/
Copy pathTypeTable.Tests.ps1
More file actions
134 lines (114 loc) · 7.11 KB
/
Copy pathTypeTable.Tests.ps1
File metadata and controls
134 lines (114 loc) · 7.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Describe "Built-in type information tests" -Tag "CI" {
BeforeAll {
$iss = [initialsessionstate]::CreateDefault2()
$rs = [runspacefactory]::CreateRunspace($iss)
$rs.Open()
$ps = [powershell]::Create()
$ps.Runspace = $rs
$types = $ps.AddCommand("Get-TypeData").Invoke()
}
AfterAll {
$ps.Dispose()
$rs.Dispose()
}
It "Should have correct number of built-in type items in type table" {
$isUnixStatEnabled = $EnabledExperimentalFeatures -contains 'PSUnixFileStat'
$expected = if ($IsWindows) {
273
} elseif ($isUnixStatEnabled) {
272
} else {
271
}
$types.Count | Should -BeExactly $expected
}
It "Should have expected member info for 'System.Diagnostics.ProcessModule'" {
$typeData = $types | Where-Object TypeName -EQ "System.Diagnostics.ProcessModule"
$typeData | Should -Not -BeNullOrEmpty
$typeData.Members.Count | Should -BeExactly 6
$typeData.Members['Size'] | Should -BeOfType System.Management.Automation.Runspaces.ScriptPropertyData
$typeData.Members['Size'].GetScriptBlock.ToString() | Should -BeExactly '$this.ModuleMemorySize / 1024'
$typeData.Members['Size'].SetScriptBlock | Should -BeNullOrEmpty
$typeData.Members['Size'].IsHidden | Should -BeFalse
$typeData.Members['Size'].Name | Should -Be "Size"
$typeData.Members['Company'] | Should -BeOfType System.Management.Automation.Runspaces.ScriptPropertyData
$typeData.Members['Company'].GetScriptBlock.ToString() | Should -BeExactly '$this.FileVersionInfo.CompanyName'
$typeData.Members['Company'].SetScriptBlock | Should -BeNullOrEmpty
$typeData.Members['Company'].IsHidden | Should -BeFalse
$typeData.Members['Company'].Name | Should -Be "Company"
$typeData.Members['FileVersion'] | Should -BeOfType System.Management.Automation.Runspaces.ScriptPropertyData
$typeData.Members['FileVersion'].GetScriptBlock.ToString() | Should -BeExactly '$this.FileVersionInfo.FileVersion'
$typeData.Members['FileVersion'].SetScriptBlock | Should -BeNullOrEmpty
$typeData.Members['FileVersion'].IsHidden | Should -BeFalse
$typeData.Members['FileVersion'].Name | Should -Be "FileVersion"
$typeData.Members['ProductVersion'] | Should -BeOfType System.Management.Automation.Runspaces.ScriptPropertyData
$typeData.Members['ProductVersion'].GetScriptBlock.ToString() | Should -BeExactly '$this.FileVersionInfo.ProductVersion'
$typeData.Members['ProductVersion'].SetScriptBlock | Should -BeNullOrEmpty
$typeData.Members['ProductVersion'].IsHidden | Should -BeFalse
$typeData.Members['ProductVersion'].Name | Should -Be "ProductVersion"
$typeData.Members['Description'] | Should -BeOfType System.Management.Automation.Runspaces.ScriptPropertyData
$typeData.Members['Description'].GetScriptBlock.ToString() | Should -BeExactly '$this.FileVersionInfo.FileDescription'
$typeData.Members['Description'].SetScriptBlock | Should -BeNullOrEmpty
$typeData.Members['Description'].IsHidden | Should -BeFalse
$typeData.Members['Description'].Name | Should -Be "Description"
$typeData.Members['Product'] | Should -BeOfType System.Management.Automation.Runspaces.ScriptPropertyData
$typeData.Members['Product'].GetScriptBlock.ToString() | Should -BeExactly '$this.FileVersionInfo.ProductName'
$typeData.Members['Product'].SetScriptBlock | Should -BeNullOrEmpty
$typeData.Members['Product'].IsHidden | Should -BeFalse
$typeData.Members['Product'].Name | Should -Be "Product"
$typeData.TypeConverter | Should -BeNullOrEmpty
$typeData.TypeAdapter | Should -BeNullOrEmpty
$typeData.IsOverride | Should -BeFalse
$typeData.SerializationMethod | Should -BeNullOrEmpty
$typeData.TargetTypeForDeserialization | Should -BeNullOrEmpty
$typeData.SerializationDepth | Should -Be 0
$typeData.DefaultDisplayProperty | Should -BeNullOrEmpty
$typeData.InheritPropertySerializationSet | Should -BeFalse
$typeData.StringSerializationSource | Should -BeNullOrEmpty
$typeData.StringSerializationSourceProperty | Should -BeNullOrEmpty
$typeData.DefaultDisplayPropertySet | Should -BeNullOrEmpty
$typeData.DefaultKeyPropertySet | Should -BeNullOrEmpty
$typeData.PropertySerializationSet | Should -BeNullOrEmpty
}
It "Should have expected member info for 'System.Management.Automation.ParameterSetMetadata'" {
$typeData = $types | Where-Object TypeName -EQ "System.Management.Automation.ParameterSetMetadata"
$typeData | Should -Not -BeNullOrEmpty
$typeData.Members.Count | Should -BeExactly 1
$typeData.Members['Flags'] | Should -BeOfType System.Management.Automation.Runspaces.CodePropertyData
$typeData.Members['Flags'].IsHidden | Should -BeFalse
$typeData.Members['Flags'].Name | Should -Be "Flags"
$typeData.TypeConverter | Should -BeNullOrEmpty
$typeData.TypeAdapter | Should -BeNullOrEmpty
$typeData.IsOverride | Should -BeFalse
$typeData.TargetTypeForDeserialization | Should -BeNullOrEmpty
$typeData.SerializationDepth | Should -Be 0
$typeData.DefaultDisplayProperty | Should -BeNullOrEmpty
$typeData.InheritPropertySerializationSet | Should -BeFalse
$typeData.StringSerializationSource | Should -BeNullOrEmpty
$typeData.StringSerializationSourceProperty | Should -BeNullOrEmpty
$typeData.DefaultDisplayPropertySet | Should -BeNullOrEmpty
$typeData.DefaultKeyPropertySet | Should -BeNullOrEmpty
$typeData.SerializationMethod | Should -BeExactly "SpecificProperties"
$typeData.PropertySerializationSet | Should -BeOfType System.Management.Automation.Runspaces.PropertySetData
[string]::Join(",", $typeData.PropertySerializationSet.ReferencedProperties) | Should -BeExactly "Position,Flags,HelpMessage"
}
It "Should have expected member info for 'System.Management.Automation.JobStateEventArgs'" {
$typeData = $types | Where-Object TypeName -EQ "System.Management.Automation.JobStateEventArgs"
$typeData | Should -Not -BeNullOrEmpty
$typeData.Members.Count | Should -BeExactly 0
$typeData.TypeConverter | Should -BeNullOrEmpty
$typeData.TypeAdapter | Should -BeNullOrEmpty
$typeData.IsOverride | Should -BeFalse
$typeData.SerializationMethod | Should -BeNullOrEmpty
$typeData.TargetTypeForDeserialization | Should -BeNullOrEmpty
$typeData.DefaultDisplayProperty | Should -BeNullOrEmpty
$typeData.InheritPropertySerializationSet | Should -BeFalse
$typeData.StringSerializationSource | Should -BeNullOrEmpty
$typeData.StringSerializationSourceProperty | Should -BeNullOrEmpty
$typeData.DefaultDisplayPropertySet | Should -BeNullOrEmpty
$typeData.DefaultKeyPropertySet | Should -BeNullOrEmpty
$typeData.SerializationDepth | Should -Be 2
}
}