mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
This restructuring moves tests to a directory name which matches the module in which the cmdlet resides which should improve the discoverability of a specific test. For tests which are not about cmdlets in a module, new directories have been created to make those tests easier to find as well
34 lines
966 B
PowerShell
34 lines
966 B
PowerShell
# http://www.newtonsoft.com/json/help/html/ParsingLINQtoJSON.htm
|
|
|
|
Describe "Json.NET LINQ Parsing" {
|
|
BeforeEach {
|
|
$jsonFile = Join-Path -Path (Join-Path $PSScriptRoot -ChildPath assets) -ChildPath TestJson.json
|
|
$jsonData = (Get-Content $jsonFile | Out-String)
|
|
$json = [Newtonsoft.Json.Linq.JObject]::Parse($jsonData)
|
|
}
|
|
|
|
It "Should return data via Item()" {
|
|
[string]$json.Item("Name") | Should Be "Zaphod Beeblebrox"
|
|
}
|
|
|
|
It "Should return data via []" {
|
|
[string]$json["Planet"] | Should Be "Betelgeuse"
|
|
}
|
|
|
|
It "Should return nested data via Item().Item()" {
|
|
[int]$json.Item("Appendages").Item("Heads") | Should Be 2
|
|
}
|
|
|
|
It "Should return nested data via [][]" {
|
|
[int]$json["Appendages"]["Arms"] | Should Be 3
|
|
}
|
|
|
|
It "Should return correct array count" {
|
|
$json["Achievements"].Count | Should Be 4
|
|
}
|
|
|
|
It "Should return array data via [n]" {
|
|
[string]$json["Achievements"][3] | Should Be "One hoopy frood"
|
|
}
|
|
}
|