<!-- #include file="../aspunit/Lib/ASPUnit.asp" -->
<!-- #include file="../bootstrap.asp" -->

<%
Call ASPUnit.AddModule( _
    ASPUnit.CreateModule( _
        "Controller Registry Tests", _
        Array( _
            ASPUnit.CreateTest("RegisteredHomeControllerIsValid"), _
            ASPUnit.CreateTest("RegisteredErrorControllerIsValid"), _
            ASPUnit.CreateTest("InvalidControllerFormatIsRejected"), _
            ASPUnit.CreateTest("InvalidActionFormatIsRejected"), _
            ASPUnit.CreateTest("UnknownControllerIsRejected") _
        ), _
        ASPUnit.CreateLifeCycle("SetupControllerRegistry", "TeardownControllerRegistry") _
    ) _
)

Call ASPUnit.Run()

Sub SetupControllerRegistry()
    Call ResetTestRuntime()
End Sub

Sub TeardownControllerRegistry()
    Call ResetTestRuntime()
End Sub

Function RegisteredHomeControllerIsValid()
    Call ASPUnit.Ok(ControllerRegistry().IsValidController("homecontroller"), "HomeController should be present in the whitelist")
End Function

Function RegisteredErrorControllerIsValid()
    Call ASPUnit.Ok(ControllerRegistry().IsValidController("errorcontroller"), "ErrorController should be present in the whitelist")
End Function

Function InvalidControllerFormatIsRejected()
    Call ASPUnit.Ok((Not ControllerRegistry().IsValidControllerFormat("home-controller")), "Controller names with dashes should be rejected")
End Function

Function InvalidActionFormatIsRejected()
    Call ASPUnit.Ok((Not ControllerRegistry().IsValidActionFormat("show-item")), "Action names with dashes should be rejected")
End Function

Function UnknownControllerIsRejected()
    Call ASPUnit.Ok((Not ControllerRegistry().IsValidController("missingcontroller")), "Unknown controllers should not pass whitelist checks")
End Function
%>
