Files
PowerShell/test/powershell/Language/Interop/DotNet/DotNetAPI.Tests.ps1
T
Dongbo Wang 86469bda33 Handle operations with ByRef-like types gracefully in PowerShell (#7533)
ByRef-like types are supposed to be used on stack only, so we need to fail gracefully when accessing properties, calling methods, or creating objects related to ByRef-like types.
2018-08-26 12:50:58 -07:00

33 lines
988 B
PowerShell

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Describe "DotNetAPI" -Tags "CI" {
$posh_E = 2.718281828459045
$posh_pi = 3.14159265358979
It "Should be able to use static .NET classes and get a constant" {
[System.Math]::E | Should -Match $posh_E.ToString()
[System.Math]::PI | Should -Match $posh_pi.ToString()
}
It "Should be able to invoke a method" {
[System.Environment]::GetEnvironmentVariable("PATH") | Should -Be $env:PATH
}
It "Should not require 'system' in front of static classes" {
[Environment]::CommandLine | Should -Be ([System.Environment]::CommandLine)
[Math]::E | Should -Be ([System.Math]::E)
}
It "Should be able to create a new instance of a .Net object" {
[System.Guid]$guidVal = [System.Guid]::NewGuid()
$guidVal | Should -BeOfType Guid
}
It "Should access types in System.Console" {
[System.Console]::TreatControlCAsInput | Should -BeFalse
}
}