From 24263a75246d65975b82be5fa25d5affa8fd0414 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Fri, 30 Oct 2015 14:43:48 -0700 Subject: [PATCH 1/2] Added test to validate ConvertTo-Csv --- src/pester-tests/ConvertTo-Csv.Tests.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/pester-tests/ConvertTo-Csv.Tests.ps1 diff --git a/src/pester-tests/ConvertTo-Csv.Tests.ps1 b/src/pester-tests/ConvertTo-Csv.Tests.ps1 new file mode 100644 index 0000000000..e256bc1b7a --- /dev/null +++ b/src/pester-tests/ConvertTo-Csv.Tests.ps1 @@ -0,0 +1,6 @@ +Describe "ConvertTo-Csv" { + It "Should Be able to be called without error" { + { Get-Process | ConvertTo-Csv } | Should Not Throw + } + +} From e884990d617a9fab38cab0766b77be0db5b0f5db Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Tue, 3 Nov 2015 11:44:51 -0800 Subject: [PATCH 2/2] added additional tests to ConvertTo-Csv tests --- src/pester-tests/ConvertTo-Csv.Tests.ps1 | 28 +++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/pester-tests/ConvertTo-Csv.Tests.ps1 b/src/pester-tests/ConvertTo-Csv.Tests.ps1 index e256bc1b7a..5c53eceb4a 100644 --- a/src/pester-tests/ConvertTo-Csv.Tests.ps1 +++ b/src/pester-tests/ConvertTo-Csv.Tests.ps1 @@ -1,6 +1,32 @@ Describe "ConvertTo-Csv" { + $Name = "Hello"; $Data = "World"; + $testObject = New-Object psobject -Property @{ FirstColumn = $Name; SecondColumn = $Data } + + It "Should Be able to be called without error" { - { Get-Process | ConvertTo-Csv } | Should Not Throw + { $testObject | ConvertTo-Csv } | Should Not Throw + } + + It "Should output an array of objects" { + $result = $testObject | ConvertTo-Csv + + $result.GetType().BaseType.Name | Should Be "Array" + } + + It "Should return the type of data in the first element of the output array" { + $result = $testObject | ConvertTo-Csv + + $result[0] | Should Be "#TYPE System.Management.Automation.PSCustomObject" + } + + It "Should return the column info in the second element of the output array" { + $result = $testObject | ConvertTo-Csv + $result[1] | Should Be "`"FirstColumn`",`"SecondColumn`"" + } + + It "Should return the data as a comma-separated list in the third element of the output array" { + $result = $testObject | ConvertTo-Csv + $result[2] | Should Be "`"Hello`",`"World`"" } }