Consolidated ASP Classic MVC framework from best components
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

81 lines
2.4KB

  1. <!-- #include file="../aspunit/Lib/ASPUnit.asp" -->
  2. <!-- #include file="../bootstrap.asp" -->
  3. <!-- #include file="../../core/mvc.asp" -->
  4. <%
  5. Class TestDispatchController_Class
  6. Private m_useLayout
  7. Private Sub Class_Initialize()
  8. m_useLayout = False
  9. End Sub
  10. Public Property Get useLayout
  11. useLayout = m_useLayout
  12. End Property
  13. Public Property Let useLayout(value)
  14. m_useLayout = value
  15. End Property
  16. Public Sub Smoke()
  17. dispatchActionRan = True
  18. End Sub
  19. End Class
  20. Dim TestDispatchController_Class__Singleton
  21. Function TestDispatchController()
  22. If IsEmpty(TestDispatchController_Class__Singleton) Then
  23. Set TestDispatchController_Class__Singleton = New TestDispatchController_Class
  24. End If
  25. Set TestDispatchController = TestDispatchController_Class__Singleton
  26. End Function
  27. Call ASPUnit.AddModule( _
  28. ASPUnit.CreateModule( _
  29. "MVC Dispatch Smoke Tests", _
  30. Array( _
  31. ASPUnit.CreateTest("RootRouteResolvesToHomeController"), _
  32. ASPUnit.CreateTest("KnownRouteDispatchCompletesWithoutLookupFailure") _
  33. ), _
  34. ASPUnit.CreateLifeCycle("SetupMvcDispatch", "TeardownMvcDispatch") _
  35. ) _
  36. )
  37. Call ASPUnit.Run()
  38. Sub SetupMvcDispatch()
  39. Call ResetTestRuntime()
  40. On Error Resume Next
  41. MVC_Dispatcher_Class__Singleton = Empty
  42. TestDispatchController_Class__Singleton = Empty
  43. On Error GoTo 0
  44. Call ExecuteGlobal("Dim dispatchActionRan")
  45. dispatchActionRan = False
  46. Call RegisterDefaultRoutes()
  47. Call ControllerRegistry().RegisterController("testdispatchcontroller")
  48. Call router.AddRoute("GET", "/dispatch-smoke", "testdispatchcontroller", "Smoke")
  49. End Sub
  50. Sub TeardownMvcDispatch()
  51. On Error Resume Next
  52. MVC_Dispatcher_Class__Singleton = Empty
  53. TestDispatchController_Class__Singleton = Empty
  54. Response.Status = "200 OK"
  55. On Error GoTo 0
  56. Call ResetTestRuntime()
  57. End Sub
  58. Function RootRouteResolvesToHomeController()
  59. Dim routeArray
  60. routeArray = router.Resolve("GET", "/")
  61. Call ASPUnit.Ok((LCase(routeArray(0)) = "homecontroller" And LCase(routeArray(1)) = "index"), "Root route should resolve to HomeController.Index")
  62. End Function
  63. Function KnownRouteDispatchCompletesWithoutLookupFailure()
  64. Call MVC().DispatchRequest("GET", "/dispatch-smoke")
  65. Call ASPUnit.Ok(dispatchActionRan, "Dispatch should reach a registered controller action without whitelist or lookup failures")
  66. End Function
  67. %>

Powered by TurnKey Linux.