mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Change some context to it
This commit is contained in:
1 parent
312ec5ffd0
commit
bbbd6a9dfc
2 files changed
+58
-66
No files matched your search
@@ -10,7 +10,8 @@ Describe 'Testing of script internationalization' -Tags "CI" {
|
|||||||
$dir=$PSScriptRoot
|
$dir=$PSScriptRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'converFromString-Data.' {
|
|
||||||
|
Context 'converFromString-Data.' {
|
||||||
|
|
||||||
data mydata
|
data mydata
|
||||||
{
|
{
|
||||||
@@ -20,29 +21,29 @@ Describe 'Testing of script internationalization' -Tags "CI" {
|
|||||||
'@
|
'@
|
||||||
}
|
}
|
||||||
|
|
||||||
$mydata.string1 | Should Be 'string1'
|
It '$mydata.string1' { $mydata.string1 | Should Be 'string1' }
|
||||||
$mydata.string2 | Should Be 'string2'
|
It '$mydata.string2' { $mydata.string2 | Should Be 'string2' }
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Import default culture' {
|
Context 'Import default culture' {
|
||||||
|
|
||||||
import-localizedData mydata;
|
import-localizedData mydata;
|
||||||
|
|
||||||
$mydata.string1 | Should Be 'string1 for en-US'
|
It '$mydata.string1' { $mydata.string1 | Should Be 'string1 for en-US' }
|
||||||
$mydata.string2 | Should be 'string2 for en-US'
|
It '$mydata.string2' { $mydata.string2 | Should be 'string2 for en-US' }
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Import specific culture' {
|
Context 'Import specific culture' {
|
||||||
|
|
||||||
import-localizedData mydata -uiculture en-US
|
import-localizedData mydata -uiculture en-US
|
||||||
|
|
||||||
$mydata.string1 | Should Be 'string1 for en-US'
|
It '$mydata.string1' { $mydata.string1 | Should Be 'string1 for en-US' }
|
||||||
$mydata.string2 | Should Be 'string2 for en-US'
|
It '$mydata.string2' { $mydata.string2 | Should Be 'string2 for en-US' }
|
||||||
|
|
||||||
import-localizedData mydata -uiculture fr-FR
|
import-localizedData mydata -uiculture fr-FR
|
||||||
|
|
||||||
$mydata.string1 | Should Be 'string1 for fr-FR'
|
It '$mydata.string1' { $mydata.string1 | Should Be 'string1 for fr-FR' }
|
||||||
$mydata.string2 | Should Be 'string2 for fr-FR'
|
It '$mydata.string2' { $mydata.string2 | Should Be 'string2 for fr-FR' }
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Import non existing culture' {
|
It 'Import non existing culture' {
|
||||||
@@ -52,51 +53,51 @@ Describe 'Testing of script internationalization' -Tags "CI" {
|
|||||||
$ev[0].Exception.GetType() | Should Be System.Management.Automation.PSInvalidOperationException
|
$ev[0].Exception.GetType() | Should Be System.Management.Automation.PSInvalidOperationException
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Import different file name' {
|
Context 'Import different file name' {
|
||||||
|
|
||||||
import-localizedData mydata -filename foo
|
import-localizedData mydata -filename foo
|
||||||
|
|
||||||
$mydata.string1 | Should Be 'string1 from foo in en-US'
|
It '$mydata.string1' { $mydata.string1 | Should Be 'string1 from foo in en-US' }
|
||||||
$mydata.string2 | Should Be 'string2 from foo in en-US'
|
It '$mydata.string2' { $mydata.string2 | Should Be 'string2 from foo in en-US' }
|
||||||
|
|
||||||
import-localizedData mydata -filename foo -uiculture fr-FR
|
import-localizedData mydata -filename foo -uiculture fr-FR
|
||||||
|
|
||||||
$mydata.string1 | Should Be 'string1 from foo in fr-FR'
|
It '$mydata.string1' { $mydata.string1 | Should Be 'string1 from foo in fr-FR' }
|
||||||
$mydata.string2 | Should Be 'string2 from foo in fr-FR'
|
It '$mydata.string2' { $mydata.string2 | Should Be 'string2 from foo in fr-FR' }
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Import different file base' {
|
Context 'Import different file base' {
|
||||||
|
|
||||||
import-localizedData mydata -basedirectory "${dir}\newbase"
|
import-localizedData mydata -basedirectory "${dir}\newbase"
|
||||||
|
|
||||||
$mydata.string1 | Should Be 'string1 for en-US under newbase'
|
It '$mydata.string1' { $mydata.string1 | Should Be 'string1 for en-US under newbase' }
|
||||||
$mydata.string2 | Should Be 'string2 for en-US under newbase'
|
It '$mydata.string2' { $mydata.string2 | Should Be 'string2 for en-US under newbase' }
|
||||||
|
|
||||||
import-localizedData mydata -basedirectory "${dir}\newbase" -uiculture fr-FR
|
import-localizedData mydata -basedirectory "${dir}\newbase" -uiculture fr-FR
|
||||||
|
|
||||||
$mydata.string1 | Should Be 'string1 for fr-FR under newbase'
|
It '$mydata.string1' { $mydata.string1 | Should Be 'string1 for fr-FR under newbase' }
|
||||||
$mydata.string2 | Should Be 'string2 for fr-FR under newbase'
|
It '$mydata.string2' { $mydata.string2 | Should Be 'string2 for fr-FR under newbase' }
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Import different file base and file name' {
|
Context 'Import different file base and file name' {
|
||||||
|
|
||||||
import-localizedData mydata -basedirectory "${dir}\newbase" -filename foo
|
import-localizedData mydata -basedirectory "${dir}\newbase" -filename foo
|
||||||
|
|
||||||
$mydata.string1 | Should Be 'string1 for en-US from foo under newbase'
|
It '$mydata.string1' { $mydata.string1 | Should Be 'string1 for en-US from foo under newbase' }
|
||||||
$mydata.string2 | Should Be 'string2 for en-US from foo under newbase'
|
It '$mydata.string2' { $mydata.string2 | Should Be 'string2 for en-US from foo under newbase' }
|
||||||
|
|
||||||
import-localizedData mydata -basedirectory "${dir}\newbase" -filename foo -uiculture fr-FR
|
import-localizedData mydata -basedirectory "${dir}\newbase" -filename foo -uiculture fr-FR
|
||||||
|
|
||||||
$mydata.string1 | Should Be 'string1 for fr-FR from foo under newbase'
|
It '$mydata.string1' { $mydata.string1 | Should Be 'string1 for fr-FR from foo under newbase' }
|
||||||
$mydata.string2 | Should Be 'string2 for fr-FR from foo under newbase'
|
It '$mydata.string2' { $mydata.string2 | Should Be 'string2 for fr-FR from foo under newbase' }
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Import variable that doesn't exist" {
|
Context "Import variable that doesn't exist" {
|
||||||
|
|
||||||
import-localizedData mydata2
|
import-localizedData mydata2
|
||||||
|
|
||||||
$mydata2.string1 | Should Be 'string1 for en-US'
|
It '$mydata.string1' { $mydata2.string1 | Should Be 'string1 for en-US' }
|
||||||
$mydata2.string2 | Should Be 'string2 for en-US'
|
It '$mydata.string2' { $mydata2.string2 | Should Be 'string2 for en-US' }
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Import bad psd1 file - tests the use of disallowed variables' {
|
It 'Import bad psd1 file - tests the use of disallowed variables' {
|
||||||
@@ -110,76 +111,68 @@ Describe 'Testing of script internationalization' -Tags "CI" {
|
|||||||
$script:exception.exception.gettype() | Should Be System.management.automation.psinvalidoperationexception
|
$script:exception.exception.gettype() | Should Be System.management.automation.psinvalidoperationexception
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Import if psd1 file' {
|
Context 'Import if psd1 file' {
|
||||||
|
|
||||||
import-localizedData mydata -filename if
|
import-localizedData mydata -filename if
|
||||||
|
|
||||||
if ($psculture -eq 'en-US')
|
if ($psculture -eq 'en-US')
|
||||||
{
|
{
|
||||||
$mydata.string1 | Should Be 'string1 for en-US in if'
|
It '$mydata.string1' { $mydata.string1 | Should Be 'string1 for en-US in if' }
|
||||||
$mydata.string2 | Should Be 'string2 for en-US in if'
|
It '$mydata.string2' { $mydata.string2 | Should Be 'string2 for en-US in if' }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mydata | Should Be $null
|
It '$mydata should not be null' { $mydata | Should Be $null }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
It 'Allowed cmdlets checked properly' {
|
$testData = @(
|
||||||
|
@{cmd = 'data d { @{ x=$(get-command)} }';Expected='*get-command*'},
|
||||||
|
@{cmd = 'data d { if ($(get-command)) {} }';Expected='*get-command*'},
|
||||||
|
@{cmd = 'data d { @(get-command) }';Expected='*get-command*'}
|
||||||
|
)
|
||||||
|
|
||||||
|
It 'Allowed cmdlets checked properly' -TestCase:$testData {
|
||||||
|
param ($cmd, $Expected)
|
||||||
|
|
||||||
$script:exception = $null
|
$script:exception = $null
|
||||||
& {
|
& {
|
||||||
trap {$script:exception = $_.Exception ; continue }
|
trap {$script:exception = $_.Exception ; continue }
|
||||||
iex 'data d { @{ x=$(get-command)} }'
|
iex $cmd
|
||||||
}
|
}
|
||||||
$exception -like '*get-command*' | Should Be $true
|
#$exception -like '*get-command*' | Should Be $true
|
||||||
|
$exception -like $Expected | Should Be $true
|
||||||
|
|
||||||
$script:exception = $null
|
|
||||||
& {
|
|
||||||
trap {$script:exception = $_.Exception ; continue }
|
|
||||||
iex 'data d { if ($(get-command)) {} }'
|
|
||||||
}
|
|
||||||
$exception -like '*get-command*' | Should Be $true
|
|
||||||
|
|
||||||
|
|
||||||
$script:exception = $null
|
|
||||||
& {
|
|
||||||
trap {$script:exception = $_.Exception ; continue }
|
|
||||||
iex 'data d { @(get-command) }'
|
|
||||||
}
|
|
||||||
$exception -like '*get-command*' | Should Be $true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
It 'Check alternate syntax that also supports complex variable names' {
|
Context 'Check alternate syntax that also supports complex variable names' {
|
||||||
|
|
||||||
& {
|
& {
|
||||||
$script:mydata = data { 123 }
|
$script:mydata = data { 123 }
|
||||||
}
|
}
|
||||||
$mydata | Should Be 123
|
It '$mydata' { $mydata | Should Be 123 }
|
||||||
|
|
||||||
$mydata = data { 456 }
|
$mydata = data { 456 }
|
||||||
& {
|
& {
|
||||||
# This import should not clobber the one at script scope
|
# This import should not clobber the one at script scope
|
||||||
import-localizedData mydata -uiculture en-US
|
import-localizedData mydata -uiculture en-US
|
||||||
}
|
}
|
||||||
$mydata | Should Be 456
|
It '$mydata' { $mydata | Should Be 456 }
|
||||||
|
|
||||||
& {
|
& {
|
||||||
# This import should clobber the one at script scope
|
# This import should clobber the one at script scope
|
||||||
import-localizedData script:mydata -uiculture en-US
|
import-localizedData script:mydata -uiculture en-US
|
||||||
}
|
}
|
||||||
$script:mydata.string1 | Should Be 'string1 for en-US'
|
It '$script:mydata.string1' { $script:mydata.string1 | Should Be 'string1 for en-US'}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
It 'Check fallback to current directory plus -SupportedCommand parameter' {
|
Context 'Check fallback to current directory plus -SupportedCommand parameter' {
|
||||||
|
|
||||||
new-alias MyConvertFrom-StringData ConvertFrom-StringData
|
new-alias MyConvertFrom-StringData ConvertFrom-StringData
|
||||||
|
|
||||||
import-localizeddata local:mydata -uiculture fr-ca -filename I18n.Tests_fallback.psd1 -SupportedCommand MyConvertFrom-StringData
|
import-localizeddata local:mydata -uiculture fr-ca -filename I18n.Tests_fallback.psd1 -SupportedCommand MyConvertFrom-StringData
|
||||||
$mydata[0].string1 | Should Be 'fallback string1 for en-US'
|
It '$mydata[0].string1' { $mydata[0].string1 | Should Be 'fallback string1 for en-US' }
|
||||||
$mydata[1] | Should Be 42
|
It '$mydata[1]' { $mydata[1] | Should Be 42 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -302,8 +302,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
It 'Common parameters should also not appear in parameters maml' { $x.parameters.parameter.Count | Should Be 2}
|
It 'Common parameters should also not appear in parameters maml' { $x.parameters.parameter.Count | Should Be 2}
|
||||||
}
|
}
|
||||||
|
|
||||||
Context 'helpFunc3 -?' {
|
It 'helpFunc3 -?' {
|
||||||
|
|
||||||
|
|
||||||
##############################################
|
##############################################
|
||||||
|
|
||||||
@@ -319,10 +318,10 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$x = helpFunc3 -?
|
$x = helpFunc3 -?
|
||||||
It '$x.Synopsis' { $x.Synopsis | Should Be "A synopsis of helpFunc3." }
|
$x.Synopsis | Should Be "A synopsis of helpFunc3."
|
||||||
}
|
}
|
||||||
|
|
||||||
Context 'get-help helpFunc4' {
|
It 'get-help helpFunc4' {
|
||||||
|
|
||||||
<#
|
<#
|
||||||
.Description
|
.Description
|
||||||
@@ -339,7 +338,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$x = get-help helpFunc4
|
$x = get-help helpFunc4
|
||||||
It '$x.Synopsis should be empty' { $x.Synopsis | Should Be "" }
|
$x.Synopsis | Should Be ""
|
||||||
}
|
}
|
||||||
|
|
||||||
Context 'get-help helpFunc5' {
|
Context 'get-help helpFunc5' {
|
||||||
@@ -439,7 +438,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
It '$x should not be $null' { $x | Should Not Be $null }
|
It '$x should not be $null' { $x | Should Not Be $null }
|
||||||
}
|
}
|
||||||
|
|
||||||
Context 'get-help helpFunc10' {
|
It 'get-help helpFunc10' {
|
||||||
#######################################################
|
#######################################################
|
||||||
# .SYNOPSIS
|
# .SYNOPSIS
|
||||||
# Help on helpFunc10
|
# Help on helpFunc10
|
||||||
@@ -449,7 +448,7 @@ Describe 'get-help other tests' -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$x = get-help helpFunc10
|
$x = get-help helpFunc10
|
||||||
It '$x.Synopsis' { $x.Synopsis | Should Be 'Help on helpFunc10' }
|
$x.Synopsis | Should Be 'Help on helpFunc10'
|
||||||
}
|
}
|
||||||
|
|
||||||
Context 'get-help helpFunc11' {
|
Context 'get-help helpFunc11' {
|
||||||
|
|||||||
Reference in new issue
Block a user