C# Class Subtext.TestLibrary.HttpSimulator

Useful class for simulating the HttpContext. This does not actually make an HttpRequest, it merely simulates the state that your code would be in "as if" handling a request. Thus the HttpContext.Current property is populated.
Inheritance: IDisposable
Mostrar archivo Open project: Tboda/abSee Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

HttpSimulator ( ) : System
HttpSimulator ( string applicationPath ) : System
HttpSimulator ( string applicationPath, string physicalApplicationPath ) : System
SetFormVariable ( string name, string value ) : HttpSimulator

Sets a form variable.

SetHeader ( string name, string value ) : HttpSimulator

Sets a header value.

SetReferer ( Uri referer ) : HttpSimulator

Sets the referer for the request. Uses a fluent interface.

SimulateRequest ( ) : HttpSimulator

Sets up the HttpContext objects to simulate a GET request.

Simulates a request to http://localhost/

SimulateRequest ( Uri url ) : HttpSimulator

Sets up the HttpContext objects to simulate a GET request.

SimulateRequest ( Uri url, HttpVerb httpVerb ) : HttpSimulator

Sets up the HttpContext objects to simulate a request.

SimulateRequest ( Uri url, HttpVerb httpVerb, NameValueCollection headers ) : HttpSimulator

Sets up the HttpContext objects to simulate a request.

SimulateRequest ( Uri url, NameValueCollection formVariables ) : HttpSimulator

Sets up the HttpContext objects to simulate a POST request.

SimulateRequest ( Uri url, NameValueCollection formVariables, NameValueCollection headers ) : HttpSimulator

Sets up the HttpContext objects to simulate a POST request.

Protected Methods

Method Description
GetHostingEnvironment ( ) : HostingEnvironment
NormalizeSlashes ( string s ) : string
SimulateRequest ( Uri url, HttpVerb httpVerb, NameValueCollection formVariables, NameValueCollection headers ) : HttpSimulator

Sets up the HttpContext objects to simulate a request.

StripPrecedingSlashes ( string s ) : string
StripTrailingBackSlashes ( string s ) : string
StripTrailingSlashes ( string s ) : string

Private Methods

Method Description
ExtractQueryStringPart ( Uri url ) : string
InitializeApplication ( ) : void
InitializeSession ( ) : void
ParseRequestUrl ( Uri url ) : void
RightAfter ( string original, string search ) : string
SetHttpRuntimeInternals ( ) : void

Method Details

Dispose() public method

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public Dispose ( ) : void
return void

GetHostingEnvironment() protected static method

protected static GetHostingEnvironment ( ) : HostingEnvironment
return System.Web.Hosting.HostingEnvironment

HttpSimulator() public method

public HttpSimulator ( ) : System
return System

HttpSimulator() public method

public HttpSimulator ( string applicationPath ) : System
applicationPath string
return System

HttpSimulator() public method

public HttpSimulator ( string applicationPath, string physicalApplicationPath ) : System
applicationPath string
physicalApplicationPath string
return System

NormalizeSlashes() protected static method

protected static NormalizeSlashes ( string s ) : string
s string
return string

SetFormVariable() public method

Sets a form variable.
public SetFormVariable ( string name, string value ) : HttpSimulator
name string
value string
return HttpSimulator

SetHeader() public method

Sets a header value.
public SetHeader ( string name, string value ) : HttpSimulator
name string
value string
return HttpSimulator

SetReferer() public method

Sets the referer for the request. Uses a fluent interface.
public SetReferer ( Uri referer ) : HttpSimulator
referer System.Uri
return HttpSimulator

SimulateRequest() public method

Sets up the HttpContext objects to simulate a GET request.
Simulates a request to http://localhost/
public SimulateRequest ( ) : HttpSimulator
return HttpSimulator

SimulateRequest() public method

Sets up the HttpContext objects to simulate a GET request.
public SimulateRequest ( Uri url ) : HttpSimulator
url System.Uri
return HttpSimulator

SimulateRequest() public method

Sets up the HttpContext objects to simulate a request.
public SimulateRequest ( Uri url, HttpVerb httpVerb ) : HttpSimulator
url System.Uri
httpVerb HttpVerb
return HttpSimulator

SimulateRequest() public method

Sets up the HttpContext objects to simulate a request.
public SimulateRequest ( Uri url, HttpVerb httpVerb, NameValueCollection headers ) : HttpSimulator
url System.Uri
httpVerb HttpVerb
headers System.Collections.Specialized.NameValueCollection
return HttpSimulator

SimulateRequest() protected method

Sets up the HttpContext objects to simulate a request.
protected SimulateRequest ( Uri url, HttpVerb httpVerb, NameValueCollection formVariables, NameValueCollection headers ) : HttpSimulator
url System.Uri
httpVerb HttpVerb
formVariables System.Collections.Specialized.NameValueCollection
headers System.Collections.Specialized.NameValueCollection
return HttpSimulator

SimulateRequest() public method

Sets up the HttpContext objects to simulate a POST request.
public SimulateRequest ( Uri url, NameValueCollection formVariables ) : HttpSimulator
url System.Uri
formVariables System.Collections.Specialized.NameValueCollection
return HttpSimulator

SimulateRequest() public method

Sets up the HttpContext objects to simulate a POST request.
public SimulateRequest ( Uri url, NameValueCollection formVariables, NameValueCollection headers ) : HttpSimulator
url System.Uri
formVariables System.Collections.Specialized.NameValueCollection
headers System.Collections.Specialized.NameValueCollection
return HttpSimulator

StripPrecedingSlashes() protected static method

protected static StripPrecedingSlashes ( string s ) : string
s string
return string

StripTrailingBackSlashes() protected static method

protected static StripTrailingBackSlashes ( string s ) : string
s string
return string

StripTrailingSlashes() protected static method

protected static StripTrailingSlashes ( string s ) : string
s string
return string