Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust typos, parameters, remove unused lines in AboutCsvCmdlets.Koans.ps1 #390

Merged
merged 2 commits into from
May 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions PSKoans/Koans/Cmdlets 2/AboutCsvCmdlets.Koans.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Describe '*-Csv Cmdlets' {

It 'stores the data accurately' {
# Now if we read the file as text, let's see what's inside!
$FileContents = Get-Content -Path "$TestDrove/Data.csv"
$FileContents = Get-Content -Path "$TestDrive/Data.csv"

<#
The headers (first line) will list the property names from the objects in question.
Expand Down Expand Up @@ -91,27 +91,24 @@ Describe '*-Csv Cmdlets' {
All data will be imported as an array of PSCustomObjects with string properties.
#>
BeforeAll {
$Letters = 'abcdefghijklmnopqrstuvwxyz'

$Objects = foreach ($number in 1..5) {
[bigint]$number
}

$CsvPath = "$TestDrive/Data.csv"
$PipeDelimitedCsvPath = "$TestDrive/Data2.csv"

$Objects | Export-Csv -Path $CsvPath -NoTypeInformation
$ImportedData = Import-Csv -Path $CsvPath
}

It 'imports the stored data as PSCustomObjects' {
# Our original data type is a .NET numeric type.
'System.____.____' | Should -Be $Objects[0].GetType()
'System.____.____' | Should -Be $Objects[0].GetType().FullName

$ImportedData | Should -NotBeNullOrEmpty
$ImportedData | Should -Not -BeNullOrEmpty

# What comes back after the import?
'System.____.____.____' | Should -Be $ImportedData[0].GetType()
'System.____.____.____' | Should -Be $ImportedData[0].GetType().FullName
}

It 'stores properties of an object, not any inherent value' {
Expand Down Expand Up @@ -150,7 +147,7 @@ Describe '*-Csv Cmdlets' {

$Animals = Import-Csv -Path $AnimalCsv -Delimiter $Delimiter

$Animals.Name | Should -NotBeNullOrEmpty
$Animals.Name | Should -Not -BeNullOrEmpty
$Animals[0].Animal | Should -Be 'Dog'
$Animals[1].Name | Should -Be 'Alice'

Expand Down Expand Up @@ -193,12 +190,12 @@ Describe '*-Csv Cmdlets' {
}

It 'operates on string data rather than directly with files' {
$CsvString = $Objects | ConvertTo-Csv
$CsvString = $Objects | ConvertTo-Csv -NoTypeInformation
$CsvString -is [____] | Should -BeTrue
}

It 'works the same way as Export-Csv' {
$CsvString = $Objects | ConvertTo-Csv
$CsvString = $Objects | ConvertTo-Csv -NoTypeInformation

'"____","____"' | Should -Be $CsvString[0]
'"__","__"' | Should -Be $CsvString[1]
Expand Down