tags:

views:

46

answers:

1

I'm trying to find a way to capture the response of ASP templates for testing purposes. After reading this post i was hoping that the following code would provide a solution:

class cMockResponse
    public data
    public sub write( value)
        if isempty(data) then data = ""
        data = data & value
    end sub
end class

class cView
    public response
    private sub class_initialize()
        set response = new cMockResponse
    end sub
    public sub render()
      ' expected that the following would be compiled to response.write "hello world"
      %> hello world <% 
    end sub        
end class

set view = new cView
call view.render()
response.write "the mock respone was:" & view.response.data

Given the blog post i hoped that

%> hello world <%

would be simply translated to

response.write "hello world"

Since response references the mock object I hoped that this solution would do the trick, but clearly it doesn't. The output of the above code is unsurprisingly:

hello world the mock response was:

Are there other methods to capture the output of ASP templates programatically without resorting to internal xmlhttp requests?

+1  A: 

As far as I am aware of it is not possible to capture the output.

If you require unit testing for classic ASP you might have a look at ajaxed

Michal