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

<%
Call ASPUnit.AddModule( _
    ASPUnit.CreateModule( _
        "Route Helper Integration Tests", _
        Array( _
            ASPUnit.CreateTest("RouteHelperReadsCacheBustingSettingFromConfig"), _
            ASPUnit.CreateTest("UrlToBuildsLowercaseControllerActionPath"), _
            ASPUnit.CreateTest("AssetUrlCanOverrideCacheBustingPerCall") _
        ), _
        ASPUnit.CreateLifeCycle("SetupRouteHelper", "TeardownRouteHelper") _
    ) _
)

Call ASPUnit.Run()

Sub SetupRouteHelper()
    Call ResetTestRuntime()
    On Error Resume Next
    Set Route_Helper__Singleton = Nothing
    On Error GoTo 0
End Sub

Sub TeardownRouteHelper()
    On Error Resume Next
    Set Route_Helper__Singleton = Nothing
    On Error GoTo 0
    Call ResetTestRuntime()
End Sub

Function RouteHelperReadsCacheBustingSettingFromConfig()
    Call ASPUnit.Ok((Not Routes().CacheBustingEnabled), "Routes helper should read disabled cache-busting from tests/web.config")
End Function

Function UrlToBuildsLowercaseControllerActionPath()
    Dim url
    url = Routes().UrlTo("HomeController", "Index", Array("id", "7"))

    Call ASPUnit.Ok((InStr(LCase(url), "/homecontroller/index?id=7") > 0), "UrlTo should build a lowercase controller/action path with query parameters")
End Function

Function AssetUrlCanOverrideCacheBustingPerCall()
    Dim url
    url = Routes().AssetUrl("css/site.css", True)

    Call ASPUnit.Ok((InStr(url, "css/site.css?v=") > 0), "AssetUrl should append the configured cache-bust parameter when override is true")
End Function
%>
