Skip to content

Commit 6268864

Browse files
committed
Add new test cases
1 parent 2dee81b commit 6268864

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

Sources/New-Query.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ function New-HtmlQueryString {
2323
[ValidateNotNull()]
2424
[OrderedDictionary] $InputObject = @{},
2525

26-
# The string providing the initial query parameters.
27-
[string] $Value,
26+
# The initial query string.
27+
[string] $Value = "",
2828

2929
# Value indicating whether to include the question mark.
3030
[Parameter(ParameterSetName = "AddQuestionMark")]

Tests/New-Query.Tests.ps1

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,27 @@
66
#>
77
Describe "New-QueryString" {
88
It "should create a query string from the specified hash table" -ForEach @(
9-
@{ Parameters = @{}; Expected = "" }
10-
@{ Parameters = [ordered]@{ Foo = "Bar"; Baz = ""; Qux = $null }; Expected = "Foo=Bar&Baz=" }
9+
@{ Value = $null; Parameters = @{}; Expected = "" }
10+
@{ Value = ""; Parameters = [ordered]@{ Foo = "Bar"; Baz = ""; Qux = $null }; Expected = "Foo=Bar&Baz=" }
11+
@{ Value = "?Foo=Bar"; Parameters = [ordered]@{ Baz = ""; Qux = $null }; Expected = "Foo=Bar&Baz=" }
1112
) {
12-
Should-BeString $expected (New-HtmlQueryString $parameters) -CaseSensitive
13+
Should-BeString $expected (New-HtmlQueryString $parameters -Value $value) -CaseSensitive
1314
}
1415

1516
It "should create a name/value collection from the specified hash table" -ForEach @(
16-
@{ Parameters = @{}; Expected = "" }
17-
@{ Parameters = [ordered]@{ Foo = "Bar"; Baz = ""; Qux = $null }; Expected = "Foo=Bar&Baz=" }
17+
@{ Value = $null; Parameters = @{}; Expected = "" }
18+
@{ Value = ""; Parameters = [ordered]@{ Foo = "Bar"; Baz = ""; Qux = $null }; Expected = "Foo=Bar&Baz=" }
19+
@{ Value = "?Foo=Bar"; Parameters = [ordered]@{ Baz = ""; Qux = $null }; Expected = "Foo=Bar&Baz=" }
1820
) {
19-
$collection = New-HtmlQueryString $parameters -AsCollection
21+
$collection = New-HtmlQueryString $parameters -Value $value -AsCollection
2022
Should-BeString $expected $collection.ToString() -CaseSensitive
2123
}
2224

2325
It "should add a question mark if required" -ForEach @(
24-
@{ Parameters = @{}; Expected = "" }
25-
@{ Parameters = [ordered]@{ Foo = "Bar"; Baz = ""; Qux = $null }; Expected = "?Foo=Bar&Baz=" }
26+
@{ Value = $null; Parameters = @{}; Expected = "" }
27+
@{ Value = ""; Parameters = [ordered]@{ Foo = "Bar"; Baz = ""; Qux = $null }; Expected = "?Foo=Bar&Baz=" }
28+
@{ Value = "?Foo=Bar"; Parameters = [ordered]@{ Baz = ""; Qux = $null }; Expected = "?Foo=Bar&Baz=" }
2629
) {
27-
Should-BeString $expected (New-HtmlQueryString $parameters -AddQuestionMark) -CaseSensitive
30+
Should-BeString $expected (New-HtmlQueryString $parameters -Value $value -AddQuestionMark) -CaseSensitive
2831
}
2932
}

0 commit comments

Comments
 (0)