Download PowerShell-master/test/powershell/SDK/Json.Tests.ps1 from MegaBites-AI/Windows-powershell: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/datasets/MegaBites-AI/Windows-powershell/resolve/main/PowerShell-master/test/powershell/SDK/Json.Tests.ps1
- Command line
-
hf download hf://datasets/MegaBites-AI/Windows-powershell/PowerShell-master/test/powershell/SDK/Json.Tests.ps1
-
curl -L -o Json.Tests.ps1 https://huggingface.co/datasets/MegaBites-AI/Windows-powershell/resolve/main/PowerShell-master/test/powershell/SDK/Json.Tests.ps1
1.08 kB
| # Copyright (c) Microsoft Corporation. | |
| # Licensed under the MIT License. | |
| # https://www.newtonsoft.com/json/help/html/ParsingLINQtoJSON.htm | |
| Describe "Json.NET LINQ Parsing" -tags "CI" { | |
| 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 -BeExactly "Zaphod Beeblebrox" | |
| } | |
| It "Should return data via []" { | |
| [string]$json["Planet"] | Should -BeExactly "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 -BeExactly "One hoopy frood" | |
| } | |
| } | |