From a50114d5daf4dd7be02c054385b69f649bd6fff1 Mon Sep 17 00:00:00 2001 From: TingLiu6 Date: Thu, 4 Aug 2016 02:54:14 -0700 Subject: [PATCH] Add Language Primitive Pester Test --- .../enginecore/LanguagePrimitive.Tests.ps1 | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/powershell/enginecore/LanguagePrimitive.Tests.ps1 diff --git a/test/powershell/enginecore/LanguagePrimitive.Tests.ps1 b/test/powershell/enginecore/LanguagePrimitive.Tests.ps1 new file mode 100644 index 000000000..ac3beb786 --- /dev/null +++ b/test/powershell/enginecore/LanguagePrimitive.Tests.ps1 @@ -0,0 +1,28 @@ +Describe "Language Primitive Tests" -Tags "CI" { + It "Equality comparison with string and non-numeric type should not be culture sensitive" { + $date = [datetime]'2005,3,10' + $val = [System.Management.Automation.LanguagePrimitives]::Equals($date, "3/10/2005") + $val | Should Be $true + } + + It "Test conversion of an PSObject with Null Base Object to bool" { + $mshObj = New-Object psobject + { [System.Management.Automation.LanguagePrimitives]::ConvertTo($mshObj, [bool]) } | Should Be $true + } + + It "Test conversion of an PSObject with Null Base Object to string" { + $mshObj = New-Object psobject + { [System.Management.Automation.LanguagePrimitives]::ConvertTo($mshObj, [string]) -eq "" } | Should Be $true + } + + It "Test conversion of an PSObject with Null Base Object to object" { + $mshObj = New-Object psobject + { $mshObj -eq [System.Management.Automation.LanguagePrimitives]::ConvertTo($mshObj, [Object]) } | Should Be $true + } + + It "Test Conversion of an IEnumerable to object[]" { + $col = [System.Diagnostics.Process]::GetCurrentProcess().Modules + $ObjArray = [System.Management.Automation.LanguagePrimitives]::ConvertTo($col, [object[]]) + $ObjArray.Length | Should Be $col.Count + } +}