@@ -6,7 +6,8 @@ Class Mock
66 Private domStr
77 Private vbStr
88 Private filePath
9-
9+ Private Parameters
10+ Private fileName
1011 'Constructor
1112 Private Sub Class_Initialize( )
1213 HTML = 0
@@ -19,12 +20,21 @@ Class Mock
1920 'On Nothingd
2021 End Sub
2122
22- '
23+ ' - Set the ASP Page to use
24+ Function SetPage(fn)
25+ fileName = fn
26+ End Function
27+
28+ ' - Process User Input State Parameters
29+ Function ProcessInput()
30+
31+ End Function
32+
2333 ' Separate Frontend from backend
2434 ' Insert variables into inline <%={var}%>
2535 ' Move Response.Writes to the Dom
2636 '
27- Function LoadFile(fileName )
37+ Function LoadFile()
2838 Dim line : line = ""
2939 Dim vbPos : vbPos = 0
3040 Dim vbNeg : vbNeg = 0
@@ -86,7 +96,10 @@ Class Mock
8696 Set fSys = Nothing
8797 End Sub
8898End Class
99+ ' -
100+
89101
102+ ' -
90103Class ResponseMock
91104 Private fileName
92105 Private filePath
@@ -154,13 +167,39 @@ Class Request
154167
155168 'body
156169 End Function
170+
171+ Private Requests
172+ Function ToMethodVal(V)
173+ If V=vbYes Then : ToMethodVal= "GET" : Else : ToMethodVal= "POST"
174+ End Function
175+
176+ Function GetParameters(Ps, P)
177+ Set Requests = CreateObject( "Scripting.Dictionary" )
178+ Dim Key , K
179+ ' Santitize Fill into Dictionary
180+ For Each K IN Ps
181+ If Requests.Exists(K)= False Then Requests.add K, "Empty"
182+ Next
183+
184+ For Each Key in Requests
185+ Requests( Key ) = InputBox( "Enter value for " & Key & ": " , "Request Builder" , Requests( Key ))
186+ Next
187+ Requests.add "_METHOD" , ToMethodVal(MsgBox( "IS METHOD TYPE GET(Yes) OR POST(No): " , vbYesNo))
188+ ' Print That Back
189+ Dim reqStr : reqStr = ""
190+ For Each Key in Requests
191+ reqStr = reqStr & "[" & Key & " := " & Requests( Key ) & "]" & vbCrLf
192+ Next
193+ MsgBox reqStr, " Request Parameters "
194+ Set P = Requests
195+ GetParameters = reqStr
196+ End Function
157197End Class
158198
159199' ----- END Request CLASS -----'
160200MsgBox " Mocking..."
161201Set Response = new ResponseMock
162202' Play Data '
163- ' TODO: Load via asp File'
164203Dim HTML
165204 HTML = "<!DOCTYPE html>" & VbCrLf & _
166205 "<html>" & VbCrLf & _
@@ -170,11 +209,25 @@ Dim HTML
170209 "<body>MokMokMok</body>" & VbCrLf & _
171210 "</html>"
172211
173- ' The Action'
212+ ' Sample Action'
174213'Response.Write HTML
175214'Response.Mock
215+ ' ======================================================'
216+ ' ======================== MAIN ========================'
217+ ' ======================================================'
218+ ' Processing Steps:
219+ ' 1 Load ASP File
220+ ' 2 Read Through For Form/QueryString/Session Variables Expected
221+ ' 3 Prompt User For values or use file(save to file after prompt for next time)
222+ ' 4 Parse File Replace Input Params with last steps
223+ ' 5 Get Mock DB Input
224+ ' Generate HTML+Execute VB
225+ ' Write HTML
226+ ' OPEN in Browser
176227
177228' Wrap ASP
178- Set MockASP = new Mock
179- MockASP.LoadFile( "Page.ASP" )
180- MockASP.WriteToFile
229+ Set MockASP = new Mock '| - Initialize a Mock ASP Object
230+ MockASP.SetPage( "Page.ASP" )
231+ MockASP.ProcessInput '| - Process User Input State Parameters
232+ MockASP.LoadFile '| - Load the ASP File
233+ MockASP.WriteToFile '| -
0 commit comments