2020-03-24 11:08:37 -07:00
|
|
|
# Copyright (c) Microsoft Corporation.
|
2018-02-13 09:23:53 -08:00
|
|
|
# Licensed under the MIT License.
|
2018-08-26 12:50:58 -07:00
|
|
|
|
2016-07-25 14:01:41 -07:00
|
|
|
Describe "DotNetAPI" -Tags "CI" {
|
2015-10-09 10:51:23 -07:00
|
|
|
|
|
|
|
|
It "Should be able to use static .NET classes and get a constant" {
|
2019-06-18 20:56:43 -07:00
|
|
|
[System.Math]::E | Should -Be 2.718281828459045
|
|
|
|
|
[System.Math]::PI | Should -Be 3.141592653589793
|
2015-10-09 10:51:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
It "Should be able to invoke a method" {
|
2019-06-18 20:56:43 -07:00
|
|
|
[System.Environment]::GetEnvironmentVariable("PATH") | Should -Be $env:PATH
|
2015-10-09 10:51:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
It "Should not require 'system' in front of static classes" {
|
2019-06-18 20:56:43 -07:00
|
|
|
[Environment]::CommandLine | Should -Be ([System.Environment]::CommandLine)
|
|
|
|
|
[Math]::E | Should -Be ([System.Math]::E)
|
2015-10-09 10:51:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
It "Should be able to create a new instance of a .Net object" {
|
2019-06-18 20:56:43 -07:00
|
|
|
[System.Guid]$guidVal = [System.Guid]::NewGuid()
|
|
|
|
|
$guidVal | Should -BeOfType Guid
|
2015-10-09 10:51:23 -07:00
|
|
|
}
|
2018-08-26 12:50:58 -07:00
|
|
|
|
|
|
|
|
It "Should access types in System.Console" {
|
2019-05-10 10:56:12 -07:00
|
|
|
$type = "System.Console" -as [type]
|
|
|
|
|
$type.GetTypeInfo().FullName | Should -BeExactly "System.Console"
|
2018-08-26 12:50:58 -07:00
|
|
|
}
|
2015-10-09 10:51:23 -07:00
|
|
|
}
|