Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

77 linhas
2.4KB

  1. Sub Test_HttpRequest_IsBoundReflectsBindState()
  2. Dim httpRequest
  3. Set httpRequest = New HttpRequest
  4. AssertFalse httpRequest.IsBound, "IsBound should be False before Bind"
  5. httpRequest.Bind New FakeAspRequest
  6. AssertTrue httpRequest.IsBound, "IsBound should be True after Bind"
  7. End Sub
  8. Sub Test_HttpRequest_ProxiesServerVariable()
  9. Dim httpRequest
  10. Dim fakeRequest
  11. Set fakeRequest = New FakeAspRequest
  12. fakeRequest.SetServerVariable "SERVER_NAME", "example.local"
  13. Set httpRequest = New HttpRequest
  14. httpRequest.Bind fakeRequest
  15. AssertEquals "example.local", httpRequest.ServerVariable("SERVER_NAME"), "ServerVariable should proxy to the bound request"
  16. End Sub
  17. Sub Test_HttpRequest_ProxiesQueryStringAndForm()
  18. Dim httpRequest
  19. Dim fakeRequest
  20. Set fakeRequest = New FakeAspRequest
  21. fakeRequest.SetQueryString "q", "hello"
  22. fakeRequest.SetForm "f", "world"
  23. Set httpRequest = New HttpRequest
  24. httpRequest.Bind fakeRequest
  25. AssertEquals "hello", httpRequest.QueryString("q"), "QueryString should proxy to the bound request"
  26. AssertEquals "world", httpRequest.Form("f"), "Form should proxy to the bound request"
  27. End Sub
  28. Sub Test_HttpRequest_ItemUsesRequestDefaultLookup()
  29. Dim httpRequest
  30. Dim fakeRequest
  31. Set fakeRequest = New FakeAspRequest
  32. fakeRequest.SetForm "name", "Ada"
  33. Set httpRequest = New HttpRequest
  34. httpRequest.Bind fakeRequest
  35. AssertEquals "Ada", httpRequest.Item("name"), "Item should fall through to the request's default lookup"
  36. End Sub
  37. Sub Test_HttpRequest_AccessingBeforeBindRaises()
  38. Dim httpRequest
  39. Dim discard
  40. Dim didRaise
  41. Set httpRequest = New HttpRequest
  42. didRaise = False
  43. On Error Resume Next
  44. Err.Clear
  45. discard = httpRequest.ServerVariable("SERVER_NAME")
  46. If Err.Number <> 0 Then didRaise = True
  47. Err.Clear
  48. On Error Goto 0
  49. AssertTrue didRaise, "Accessing an unbound HttpRequest should raise"
  50. End Sub
  51. RunTest "HttpRequest: IsBound reflects Bind state", "Test_HttpRequest_IsBoundReflectsBindState"
  52. RunTest "HttpRequest: ServerVariable proxies to bound request", "Test_HttpRequest_ProxiesServerVariable"
  53. RunTest "HttpRequest: QueryString and Form proxy to bound request", "Test_HttpRequest_ProxiesQueryStringAndForm"
  54. RunTest "HttpRequest: Item uses the request's default lookup", "Test_HttpRequest_ItemUsesRequestDefaultLookup"
  55. RunTest "HttpRequest: accessing before Bind raises", "Test_HttpRequest_AccessingBeforeBindRaises"

Powered by TurnKey Linux.