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

<%
Call ASPUnit.AddModule( _
    ASPUnit.CreateModule( _
        "Helper Function Tests", _
        Array( _
            ASPUnit.CreateTest("TrimQueryParamsStripsQuestionString"), _
            ASPUnit.CreateTest("TrimQueryParamsStripsAmpersandSuffix"), _
            ASPUnit.CreateTest("TrimQueryParamsLeavesPathWithoutDelimiters"), _
            ASPUnit.CreateTest("SurroundStringInArrayWrapsStringValues"), _
            ASPUnit.CreateTest("SurroundStringInArrayLeavesNumericValuesUntouched"), _
            ASPUnit.CreateTest("SurroundStringInArrayLeavesArraysWithoutStringsUntouched") _
        ), _
        ASPUnit.CreateLifeCycle("SetupHelpers", "TeardownHelpers") _
    ) _
)

Call ASPUnit.Run()

Sub SetupHelpers()
    Call ResetTestRuntime()
End Sub

Sub TeardownHelpers()
    Call ResetTestRuntime()
End Sub

Function TrimQueryParamsStripsQuestionString()
    Call ASPUnit.Equal(TrimQueryParams("/home?id=7"), "/home", "TrimQueryParams should remove query string values after ?")
End Function

Function TrimQueryParamsStripsAmpersandSuffix()
    Call ASPUnit.Equal(TrimQueryParams("/home&debug=true"), "/home", "TrimQueryParams should remove suffix values after &")
End Function

Function TrimQueryParamsLeavesPathWithoutDelimiters()
    Call ASPUnit.Equal(TrimQueryParams("/home"), "/home", "TrimQueryParams should leave clean paths unchanged")
End Function

Function SurroundStringInArrayWrapsStringValues()
    Dim arr
    arr = Array("alpha", 2)
    arr = SurroundStringInArray(arr)

    Call ASPUnit.Equal(arr(0), """alpha""", "SurroundStringInArray should wrap string items in double quotes")
End Function

Function SurroundStringInArrayLeavesNumericValuesUntouched()
    Dim arr
    arr = Array("alpha", 2)
    arr = SurroundStringInArray(arr)

    Call ASPUnit.Equal(arr(1), 2, "SurroundStringInArray should leave non-string items unchanged")
End Function

Function SurroundStringInArrayLeavesArraysWithoutStringsUntouched()
    Dim arr
    arr = Array(1, 2)
    arr = SurroundStringInArray(arr)

    Call ASPUnit.Ok((arr(0) = 1 And arr(1) = 2), "SurroundStringInArray should leave arrays without string members unchanged")
End Function
%>
