| |
| |
|
|
| Describe "Isolated module scenario - load the whole module in custom ALC" -Tag 'CI' { |
| It "Loading 'IsolatedModule' should work as expected" { |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| [System.Runtime.Loader.AssemblyLoadContext]::Default.Assemblies | |
| Where-Object FullName -Like 'System.CommandLine,*' | |
| Should -Be $null |
|
|
| $module = Import-Module IsolatedModule -PassThru |
| $nestedCmd = Get-Command Test-NestedCommand |
| $rootCmd = Get-Command Test-RootCommand |
|
|
| $module.ModuleType | Should -Be "Binary" |
| $module.RootModule | Should -Not -BeNullOrEmpty |
|
|
| |
| $context1 = [System.Runtime.Loader.AssemblyLoadContext]::GetLoadContext($nestedCmd.ImplementingType.Assembly) |
| $context2 = [System.Runtime.Loader.AssemblyLoadContext]::GetLoadContext([Test.Isolated.Nested.Foo].Assembly) |
| $context1.Name | Should -BeExactly "MyCustomALC" |
| $context1 | Should -Be $context2 |
|
|
| |
| $foo = [Test.Isolated.Nested.Foo]::new("Hello", "World") |
| Test-NestedCommand -Param $foo | Should -BeExactly "Hello-World-System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" |
|
|
| |
| [System.Runtime.Loader.AssemblyLoadContext]::Default.Assemblies | |
| Where-Object FullName -Like 'System.CommandLine,*' | |
| Should -Be $null |
|
|
| |
| $context3 = [System.Runtime.Loader.AssemblyLoadContext]::GetLoadContext($rootCmd.ImplementingType.Assembly) |
| $context4 = [System.Runtime.Loader.AssemblyLoadContext]::GetLoadContext([Test.Isolated.Root.Red].Assembly) |
| $context3.Name | Should -BeExactly "MyCustomALC" |
| $context3 | Should -Be $context4 |
| $context3 | Should -Be $context1 |
|
|
| |
| $red = [Test.Isolated.Root.Red]::new("RED!") |
| Test-RootCommand -Param $red | Should -BeExactly "RED!" |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| Remove-Module IsolatedModule |
| { [Test.Isolated.Nested.Bar] } | Should -Throw -ErrorId "TypeNotFound" |
| { [Test.Isolated.Root.Yellow] } | Should -Throw -ErrorId "TypeNotFound" |
| } |
|
|
| It "WSMan and Certificate providers should reference the manifest module instead of the nested module" -Skip:(!$IsWindows) { |
| $wsManModule = Import-Module Microsoft.WSMan.Management -PassThru |
| $securityModule = Import-Module Microsoft.PowerShell.Security -PassThru |
|
|
| $wsManModule.ModuleType | Should -Be "Manifest" |
| $securityModule.ModuleType | Should -Be "Manifest" |
|
|
| |
| $wsManProvider = Get-PSProvider WSMan |
| $certificateProvider = Get-PSProvider Certificate |
|
|
| $wsManProvider.Module | Should -Be $wsManModule |
| $certificateProvider.Module | Should -Be $securityModule |
| } |
| } |
|
|