@@ -224,6 +224,15 @@ Public Function Specs() As SpecSuite
224224 .Expect(Request.FormattedResource).ToEqual "A/B/C/D"
225225 End With
226226
227+ With Specs.It("FormattedResource should url-encode Url Segments" )
228+ Set Request = New WebRequest
229+
230+ Request.Resource = "{segment}"
231+ Request.AddUrlSegment "segment" , "$&+,/:;=?@"
232+
233+ .Expect(Request.FormattedResource).ToEqual "%24%26%2B%2C%2F%3A%3B%3D%3F%40"
234+ End With
235+
227236 With Specs.It("FormattedResource should include querystring parameters" )
228237 Set Request = New WebRequest
229238
@@ -302,24 +311,6 @@ Public Function Specs() As SpecSuite
302311 .Expect(Request.Body).ToEqual "{""A"":123,""B"":456}"
303312 End With
304313
305- ' TODO
306- 'With Specs.It("AddBodyParameter should throw TODO if adding to existing Body this is not Dictionary")
307- ' On Error Resume Next
308- ' Set Request = New WebRequest
309- '
310- ' Request.Body = Array("A", "B", "C")
311- ' Request.AddBodyParameter "D", 123
312- '
313- ' ' TODO Check actual error number
314- ' .Expect(Err.Number).ToNotEqual 0
315- ' Debug.Print Err.Number & ": " & Err.Description
316- ' .Expect(Err.Description).ToEqual _
317- ' "The existing body is not a Dictionary. Adding body parameters can only be used with Dictionaries"
318- '
319- ' Err.Clear
320- ' On Error GoTo 0
321- 'End With
322-
323314 ' AddCookie
324315 ' --------------------------------------------- '
325316 With Specs.It("should AddCookie" )
@@ -346,6 +337,21 @@ Public Function Specs() As SpecSuite
346337 .Expect(Request.Headers(2 )("Value" )).ToEqual "header 2"
347338 End With
348339
340+ ' SetHeader
341+ ' --------------------------------------------- '
342+ With Specs.It("should SetHeader" )
343+ Set Request = New WebRequest
344+
345+ Request.AddHeader "A" , "add"
346+
347+ Request.SetHeader "A" , "set"
348+ Request.SetHeader "B" , "header"
349+
350+ .Expect(Request.Headers.Count).ToEqual 2
351+ .Expect(Request.Headers(1 )("Value" )).ToEqual "set"
352+ .Expect(Request.Headers(2 )("Key" )).ToEqual "B"
353+ End With
354+
349355 ' AddQuerystringParam
350356 ' --------------------------------------------- '
351357 With Specs.It("should AddQuerystringParam" )
0 commit comments