/
githubmirror
/
PowerShell
Обзор
Документация
Войти
/
githubmirror
/
PowerShell
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/powershell/Modules/Microsoft.PowerShell.Management/Rename-Item.Tests.ps1
57 строк
2 KB
xtqqczze
Use correct casing for cmdlet name and cmdlet parameter name in *.ps1 files (#12584)
07 май 2020, 15:00
Не верифицирован
07 май 2020, 15:00
f438220
Код
Авторство
О чём код?
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. Describe "Rename-Item tests" -Tag "CI" { BeforeAll { Setup -f originalFile.txt -Content "This is content" $source = "$TESTDRIVE/originalFile.txt" $target = "$TESTDRIVE/ItemWhichHasBeenRenamed.txt" Setup -f [orig-file].txt -Content "This is not content" $sourceSp = "$TestDrive/``[orig-file``].txt" $targetSpName = "ItemWhichHasBeen[Renamed].txt" $targetSp = "$TestDrive/ItemWhichHasBeen``[Renamed``].txt" Setup -Dir [test-dir] $wdSp = "$TestDrive/``[test-dir``]" } It "Rename-Item will rename a file" { Rename-Item $source $target Test-Path $source | Should -BeFalse Test-Path $target | Should -BeTrue "$target" | Should -FileContentMatchExactly "This is content" } It "Rename-Item will rename a file when path contains special char" { Rename-Item $sourceSp $targetSpName $sourceSp | Should -Not -Exist $targetSp | Should -Exist $targetSp | Should -FileContentMatchExactly "This is not content" } It "Rename-Item will rename a file when -Path and CWD contains special char" { $content = "This is content" $oldSpName = "[orig]file.txt" $oldSpBName = "``[orig``]file.txt" $oldSp = "$wdSp/$oldSpBName" $newSpName = "[renamed]file.txt" $newSp = "$wdSp/``[renamed``]file.txt" In $wdSp -execute { $null = New-Item -Name $oldSpName -ItemType File -Value $content -Force Rename-Item -Path $oldSpBName $newSpName } $oldSp | Should -Not -Exist $newSp | Should -Exist $newSp | Should -FileContentMatchExactly $content } It "Rename-Item will rename a file when -LiteralPath and CWD contains special char" { $content = "This is not content" $oldSpName = "[orig]file2.txt" $oldSpBName = "``[orig``]file2.txt" $oldSp = "$wdSp/$oldSpBName" $newSpName = "[renamed]file2.txt" $newSp = "$wdSp/``[renamed``]file2.txt" In $wdSp -execute { $null = New-Item -Name $oldSpName -ItemType File -Value $content -Force Rename-Item -LiteralPath $oldSpName $newSpName } $oldSp | Should -Not -Exist $newSp | Should -Exist $newSp | Should -FileContentMatchExactly $content } }