I'm trying to mock out an SSL HttpRequest but I'm having trouble figuring out how to set the protocol to HTTPS in the request object. I got started from an example from Phil Haack here: http://haacked.com/archive/2005/06/11/simulating_httpcontext.aspx
Is there a way to set the request to SSL?
public class MockHttpRequest : SimpleWorkerRequest
{
private string _Host;
public MockHttpRequest(
string appVirtualDir, string appPhysicalDir, string page, string query, TextWriter output, string host) :
base(appVirtualDir, appPhysicalDir, page, query, output)
{
if (string.IsNullOrEmpty(host))
{
throw new ArgumentException("Host must be provided.");
}
_Host = host;
}
}
public static class UnitTestingHelper
{
public static HttpContext CreateMockHttpContext(string host, string page)
{
string appVirtualDir = "/";
string appPhysicalDir = @"C:\Documents and Settings\user\My Documents\Workspace\Project\";
string query = string.Empty;
TextWriter output = null;
MockHttpRequest request
= new MockHttpRequest(appVirtualDir, appPhysicalDir, "default.aspx", query, output, host);
// How to make the request HTTPS?
HttpContext context = new HttpContext(request);
return new HttpContext(request);
}
}