Tests/Get-AppKeyValue.Tests.ps1
Describe "Get-AppKeyValue" { function New-AppJson { Param( # path to create the new file in [Parameter(Mandatory=$true)] [string] $Path ) Set-Content -Value '{"name": "testapp", "publisher": "test publisher", "brief": "this is the app brief"}' -Path (Join-Path $Path 'app.json') } Context "When the app key exists" { New-AppJson -Path $TestDrive It "should return the value of the key" { Get-AppKeyValue -SourcePath $TestDrive -KeyName 'brief' | should be 'this is the app brief' } } Context "When the app key does not exist" { New-AppJson -Path $TestDrive It "should return blank" { Get-AppKeyValue -SourcePath $TestDrive -KeyName 'nonsense' | should be '' } } } |