Programmatic indentation and whitespace-cleanup of tests

This commit is contained in:
Andrew Schwartzmeyer committed 2016-03-04 14:52:27 -08:00
1 parent 0aaf74bdcc
commit 0c6b14adab
10 files changed
+61 -63

No files matched your search

+1 -1
View File
@@ -154,7 +154,7 @@ Describe "Compare-Object" {
$actualOutput[3].SideIndicator | Should be "<="
}
# Clean up after yourself
# Clean up after yourself
Remove-Item $testDirectory -Recurse -Force
Test-Path $testDirectory | Should Be $false
}
+2 -2
View File
@@ -5,8 +5,8 @@ Describe "ConvertFrom-Csv" {
$testcsv = Join-Path -Path (Join-Path -Path $here -ChildPath assets) -ChildPath TestCsv2.csv
$testName = "Zaphod BeebleBrox"
$testColumns = @"
a,b,c
1,2,3
a,b,c
1,2,3
"@
It "Should be able to be called" {
{ ConvertFrom-Csv -InputObject $testObject } | Should Not Throw
@@ -1,8 +1,8 @@
Describe "ConvertFrom-StringData" {
$sampleData = @'
foo = 0
bar = 1
bazz = 2
foo = 0
bar = 1
bazz = 2
'@
It "Should not throw when called with just the stringdata switch" {
+1 -1
View File
@@ -84,7 +84,7 @@ Describe "Get-Variable" {
$actual | Where-Object { $_.Name -eq "var3" } | Should Not BeNullOrEmpty
}
Context "Scope Tests" {
Context "Scope Tests" {
# This will violate the DRY principle. Tread softly.
It "Should be able to get a global scope variable using the global switch" {
New-Variable globalVar -Value 1 -Scope global -Force
+10 -10
View File
@@ -27,19 +27,19 @@ Describe "Import-Csv" {
$testContent = $($(Import-Csv $testCsv -Header $header) | Get-Member) | ? { $_.MemberType -eq "NoteProperty" } | % { $_.Name } | Select-Object -First 3
# the original csv file doesn't contain the headers
$originalContent.IndexOf($header[0]) | Should Be -1
$originalContent.IndexOf($header[0]) | Should Be -1
# but it does with the -Header switch!
$testContent[0] | Should Be $header[0]
$testContent[1] | Should Be $header[1]
$testContent[2] | Should Be $header[2]
}
# but it does with the -Header switch!
$testContent[0] | Should Be $header[0]
$testContent[1] | Should Be $header[1]
$testContent[2] | Should Be $header[2]
}
It "Should be able to use the alias without error" {
It "Should be able to use the alias without error" {
{ Import-Csv $testCsv } | Should Not Throw
}
}
It "Should have the same output between the alias and the full cmdlet name" {
It "Should have the same output between the alias and the full cmdlet name" {
$alias = $($(ipcsv $testCsv) | Get-Member) | ? { $_.MemberType -eq "NoteProperty" } | % { $_.Name } | Select-Object -First 1
$cmdlet = $($(Import-Csv $testCsv) | Get-Member) | ? { $_.MemberType -eq "NoteProperty" } | % { $_.Name } | Select-Object -First 1
@@ -47,5 +47,5 @@ Describe "Import-Csv" {
$alias[1] | Should Be $cmdlet[1]
$alias[2] | Should Be $cmdlet[2]
}
}
}
+11 -11
View File
@@ -10,26 +10,26 @@ Describe "Import-LocalizedData" {
It "Should be able to import string using default culture" {
# Set-Culture is broken, but let's verify that default culture is en-US
$culture = Get-Culture
$culture.Name | Should Be "en-US"
$culture = Get-Culture
$culture.Name | Should Be "en-US"
$d = Import-LocalizedData -FileName $script -BaseDirectory $assetsDir
$d.d0 | Should be $sunday
}
$d = Import-LocalizedData -FileName $script -BaseDirectory $assetsDir
$d.d0 | Should be $sunday
}
It "Should be able to import string using en-US culture" {
It "Should be able to import string using en-US culture" {
$d = Import-LocalizedData -FileName $script -BaseDirectory $assetsDir -UICulture en-US
$d.d0 | Should be $sunday
}
}
It "Should be able to import string using de-DE culture" {
It "Should be able to import string using de-DE culture" {
$d = Import-LocalizedData -FileName $script -BaseDirectory $assetsDir -UICulture de-DE
$d.d0 | Should be $sundayInGerman
}
}
It "Should be able to import string and store in binding variable" {
It "Should be able to import string and store in binding variable" {
Import-LocalizedData -FileName $script -BaseDirectory $assetsDir -UICulture de-DE -BindingVariable d
$d.d0 | Should be $sundayInGerman
}
}
}
+23 -23
View File
@@ -76,42 +76,42 @@ Describe "New-Variable" {
Context "Option tests" {
BeforeEach {
# verify that the test variable doesn't exist
!!$var1 | Should Be $false
}
It "Should be able to use the options switch without error" {
!!$var1 | Should Be $false
}
It "Should be able to use the options switch without error" {
{ New-Variable -Name var1 -Value 2 -Option Unspecified } | Should Not Throw
}
}
It "Should default to none as the value for options" {
It "Should default to none as the value for options" {
New-Variable -Name var2 -Value 4 -PassThru| Format-List | Out-String | Should Match "Options : None"
}
}
It "Should be able to set ReadOnly option" {
It "Should be able to set ReadOnly option" {
{ New-Variable -Name var1 -Value 2 -Option ReadOnly } | Should Not Throw
}
}
It "Should not be able to change variable created using the ReadOnly option when the Force switch is not used" {
It "Should not be able to change variable created using the ReadOnly option when the Force switch is not used" {
New-Variable -Name var1 -Value 1 -Option ReadOnly
Set-Variable -Name var1 -Value 2 -ErrorAction SilentlyContinue
$var1 | Should Not Be 2
}
}
It "Should be able to set a new variable to constant" {
It "Should be able to set a new variable to constant" {
{ New-Variable -Name var1 -Option Constant } | Should Not Throw
}
}
It "Should not be able to change an existing variable to constant" {
It "Should not be able to change an existing variable to constant" {
New-Variable -Name var1 -Value 1 -PassThru
Set-Variable -Name var1 -Option Constant -ErrorAction SilentlyContinue
$var1 | Format-List | Out-String | Should Not Match "Options : None"
}
}
It "Should not be able to delete a constant variable" {
It "Should not be able to delete a constant variable" {
New-Variable -Name var1 -Value 2 -Option Constant
Remove-Variable -Name var1 -ErrorAction SilentlyContinue
@@ -119,29 +119,29 @@ Describe "New-Variable" {
!!$var1 | Should Be $true
$var1 | Should Be 2
}
}
It "Should not be able to change a constant variable" {
It "Should not be able to change a constant variable" {
New-Variable -Name var1 -Value 1 -Option Constant
Set-Variable -Name var1 -Value 2 -ErrorAction SilentlyContinue
$var1 | Should Not Be 2
}
}
It "Should be able to create a variable as private without error" {
It "Should be able to create a variable as private without error" {
{ New-Variable -Name var1 -Option Private } | Should Not Throw
}
}
It "Should be able to see the value of a private variable when within scope" {
It "Should be able to see the value of a private variable when within scope" {
New-Variable -Name var1 -Value 100 -Option Private
$var1 | Should Be 100
}
}
It "Should not be able to see the value of a private variable when out of scope" {
It "Should not be able to see the value of a private variable when out of scope" {
{
New-Variable -Name var1 -Value 1 -Option Private
}
@@ -7,7 +7,7 @@ Describe "Remove-PSBreakpoint" {
# this is a comment
Get-Date
"
"
$script > $testScript
-2
View File
@@ -112,5 +112,3 @@ Describe "Select-Object" {
$dirObject[$TestLength].Size | Should Be ($orig2 + 1)
}
}
+9 -9
View File
@@ -3,13 +3,13 @@ Describe "Wait-Event" {
Context "Validate Wait-Event is waiting for events" {
It "Should time out when it does not receive a FakeEvent" {
# Don't depend on Measure-Command
$stopwatch = [System.Diagnostics.Stopwatch]::startNew()
# Testing the the timeout, so wait for an event that will never be
# raised because it is fake
Wait-Event -Timeout 1 -SourceIdentifier "FakeEvent"
$stopwatch.Stop()
$stopwatch.ElapsedMilliseconds | Should BeGreaterThan 500
$stopwatch.ElapsedMilliseconds | Should BeLessThan 1500
}
}
$stopwatch = [System.Diagnostics.Stopwatch]::startNew()
# Testing the the timeout, so wait for an event that will never be
# raised because it is fake
Wait-Event -Timeout 1 -SourceIdentifier "FakeEvent"
$stopwatch.Stop()
$stopwatch.ElapsedMilliseconds | Should BeGreaterThan 500
$stopwatch.ElapsedMilliseconds | Should BeLessThan 1500
}
}
}