Skip to content

Commit 25dbc68

Browse files
sethvsiSazonov
authored andcommitted
Fix formatting in Add-Content.Tests.ps1 file. (#6591)
* Fix formatting. * Capitalize TestDrive and add empty strings.
1 parent 118f771 commit 25dbc68

1 file changed

Lines changed: 24 additions & 16 deletions

File tree

test/powershell/Modules/Microsoft.PowerShell.Management/Add-Content.Tests.ps1

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,50 @@ Describe "Add-Content cmdlet tests" -Tags "CI" {
55
Setup -File "$file1"
66

77
Context "Add-Content should actually add content" {
8-
It "should Add-Content to testdrive:\$file1" {
9-
$result=add-content -path testdrive:\$file1 -value "ExpectedContent" -passthru
10-
$result| Should -BeExactly "ExpectedContent"
8+
It "should Add-Content to TestDrive:\$file1" {
9+
$result = Add-Content -Path TestDrive:\$file1 -Value "ExpectedContent" -PassThru
10+
$result | Should -BeExactly "ExpectedContent"
1111
}
12-
It "should return expected string from testdrive:\$file1" {
13-
$result = get-content -path testdrive:\$file1
12+
13+
It "should return expected string from TestDrive:\$file1" {
14+
$result = Get-Content -Path TestDrive:\$file1
1415
$result | Should -BeExactly "ExpectedContent"
1516
}
16-
It "should Add-Content to testdrive:\dynamicfile.txt with dynamic parameters" -Pending:($IsLinux -Or $IsMacOS) {#https://github.com/PowerShell/PowerShell/issues/891
17-
$result=add-content -path testdrive:\dynamicfile.txt -value "ExpectedContent" -passthru
18-
$result| Should -BeExactly "ExpectedContent"
17+
18+
It "should Add-Content to TestDrive:\dynamicfile.txt with dynamic parameters" -Pending:($IsLinux -Or $IsMacOS) {#https://github.com/PowerShell/PowerShell/issues/891
19+
$result = Add-Content -Path TestDrive:\dynamicfile.txt -Value "ExpectedContent" -PassThru
20+
$result | Should -BeExactly "ExpectedContent"
1921
}
20-
It "should return expected string from testdrive:\dynamicfile.txt" -Pending:($IsLinux -Or $IsMacOS) {#https://github.com/PowerShell/PowerShell/issues/891
21-
$result = get-content -path testdrive:\dynamicfile.txt
22+
23+
It "should return expected string from TestDrive:\dynamicfile.txt" -Pending:($IsLinux -Or $IsMacOS) {#https://github.com/PowerShell/PowerShell/issues/891
24+
$result = Get-Content -Path TestDrive:\dynamicfile.txt
2225
$result | Should -BeExactly "ExpectedContent"
2326
}
24-
It "should Add-Content to testdrive:\$file1 even when -Value is `$null" {
25-
$AsItWas=get-content testdrive:\$file1
26-
{add-content -path testdrive:\$file1 -value $null -ErrorAction Stop} | Should -Not -Throw
27-
get-content testdrive:\$file1 | Should -BeExactly $AsItWas
27+
28+
It "should Add-Content to TestDrive:\$file1 even when -Value is `$null" {
29+
$AsItWas = Get-Content -Path TestDrive:\$file1
30+
{ Add-Content -Path TestDrive:\$file1 -Value $null -ErrorAction Stop } | Should -Not -Throw
31+
Get-Content -Path TestDrive:\$file1 | Should -BeExactly $AsItWas
2832
}
33+
2934
It "should throw 'ParameterArgumentValidationErrorNullNotAllowed' when -Path is `$null" {
3035
{ Add-Content -Path $null -Value "ShouldNotWorkBecausePathIsNull" -ErrorAction Stop } | Should -Throw -ErrorId "ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddContentCommand"
3136
}
37+
3238
#[BugId(BugDatabase.WindowsOutOfBandReleases, 903880)]
3339
It "should throw `"Cannot bind argument to parameter 'Path'`" when -Path is `$()" {
3440
{ Add-Content -Path $() -Value "ShouldNotWorkBecausePathIsInvalid" -ErrorAction Stop } | Should -Throw -ErrorId "ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddContentCommand"
3541
}
42+
3643
#[BugId(BugDatabase.WindowsOutOfBandReleases, 906022)]
3744
It "should throw 'NotSupportedException' when you add-content to an unsupported provider" -Skip:($IsLinux -Or $IsMacOS) {
3845
{ Add-Content -Path HKLM:\\software\\microsoft -Value "ShouldNotWorkBecausePathIsUnsupported" -ErrorAction Stop } | Should -Throw -ErrorId "NotSupported,Microsoft.PowerShell.Commands.AddContentCommand"
3946
}
47+
4048
#[BugId(BugDatabase.WindowsOutOfBandReleases, 9058182)]
4149
It "should be able to pass multiple [string]`$objects to Add-Content through the pipeline to output a dynamic Path file" -Pending:($IsLinux -Or $IsMacOS) {#https://github.com/PowerShell/PowerShell/issues/891
42-
"hello","world"|add-content testdrive:\dynamicfile2.txt
43-
$result=get-content testdrive:\dynamicfile2.txt
50+
"hello","world" | Add-Content -Path TestDrive:\dynamicfile2.txt
51+
$result = Get-Content -Path TestDrive:\dynamicfile2.txt
4452
$result.length | Should -Be 2
4553
$result[0] | Should -BeExactly "hello"
4654
$result[1] | Should -BeExactly "world"

0 commit comments

Comments
 (0)