tests/ConvertTo-Ini.Test.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
<#/* * @Author: Joseph Iannone * @Date: 2023-02-08 09:32:58 * @Last Modified by: Joseph Iannone * @Last Modified time: 2023-02-08 09:32:58 */#> # Pester v5 required BeforeAll { # Get module root $script:PSModuleRoot = (Get-Item $PSScriptRoot).parent.fullname # Import module Import-Module "$($script:PSModuleRoot)\IniConverter.psd1" } Describe 'ConvertTo-Ini' { It 'Converts PSObject to Ini text string' { # Object to convert $obj = [PSCustomObject]@{ Test1 = "hello" Test2 = "world" Test3 = 123456 Test4 = 123.456 Profile = [PSCustomObject]@{ Name = "Joe" Occupation = "Applications Developer" } EmptySection = @{} Address = [PSCustomObject]@{ Street = "123 Main Street" City = "Philadelphia" State = "PA" ZipCode = 123456 } Test5 = $null Test6 = "" } # Expected output string $expected = Get-Content "$($script:PSModuleRoot)\tests\test_input_001.ini" | Out-String # Convert $ini = $obj | ConvertTo-Ini # Assert $ini.Trim() | Should -BeExactly $expected.Trim() } } |