|
- Option Explicit
-
- Dim app, ctrl, statusLine, contentType, body, pass
- pass = True
-
- On Error Resume Next
- Set app = CreateObject("WscMvc.Application")
- If Err.Number <> 0 Then
- WScript.Echo "FAIL: could not create WscMvc.Application - " & Err.Description
- pass = False
- Err.Clear
- End If
- On Error Goto 0
-
- If pass Then
- statusLine = ""
- contentType = ""
- body = ""
- On Error Resume Next
- app.Run "/hello", statusLine, contentType, body
- If Err.Number <> 0 Then
- WScript.Echo "FAIL: Application.Run raised error on /hello - " & Err.Description
- pass = False
- Err.Clear
- End If
- On Error Goto 0
- End If
-
- If pass Then
- If statusLine = "200 OK" And contentType = "text/html; charset=utf-8" And body = "Hello from WSC-MVC!" Then
- WScript.Echo "PASS: /hello -> " & statusLine & " | " & contentType & " | " & body
- Else
- WScript.Echo "FAIL: unexpected /hello result -> [" & statusLine & "] [" & contentType & "] [" & body & "]"
- pass = False
- End If
- End If
-
- If pass Then
- statusLine = ""
- contentType = ""
- body = ""
- On Error Resume Next
- app.Run "/does-not-exist", statusLine, contentType, body
- If Err.Number <> 0 Then
- WScript.Echo "FAIL: Application.Run raised error on unknown route - " & Err.Description
- pass = False
- Err.Clear
- End If
- On Error Goto 0
- End If
-
- If pass Then
- If statusLine = "404 Not Found" Then
- WScript.Echo "PASS: unknown route -> " & statusLine
- Else
- WScript.Echo "FAIL: unexpected unknown-route result -> [" & statusLine & "]"
- pass = False
- End If
- End If
-
- Set app = Nothing
-
- If pass Then
- WScript.Echo "RESULT: ALL PASS"
- WScript.Quit 0
- Else
- WScript.Echo "RESULT: FAILURE"
- WScript.Quit 1
- End If
|