public static void SimulateForm(this FakeHttpApplication self, NameValueCollection formData, int responseStatusCode = 200)
 {
     self.SimulateRequest(req =>
     {
         req.SetHttpMethod("POST");
         req.Unvalidated.Form.Clear();
         req.Unvalidated.Form.Add(formData);
     }, () => new FakeHttpResponse()
     {
         StatusCode = responseStatusCode
     });
 }
        public static void SimulateRequest(this FakeHttpApplication self, Action <FakeHttpRequest> customizeRequest,
                                           Func <HttpResponseBase> responseFactory = null)
        {
            Func <HttpResponseBase> createResponse = responseFactory ?? (() => new FakeHttpResponse());

            self.Reset();
            customizeRequest(self.Request);
            var eventHandler = new ClassicRequestEventHandler(self);

            eventHandler.OnBeginRequest();
            self.Response = createResponse();
            eventHandler.OnLogRequest();
        }
 public static void SimulateRequest(this FakeHttpApplication self, string httpMethod = "GET", string httpUrl = "https://www.example.org/", int httpStatusCode = 200, int sleepDurationMilliseconds = 0)
 {
     self.SimulateRequest(req =>
     {
         req.SetRawUrl(httpUrl);
         req.SetHttpMethod(httpMethod);
     },
                          () =>
     {
         if (sleepDurationMilliseconds > 0)
         {
             Thread.Sleep(sleepDurationMilliseconds);
         }
         return(new FakeHttpResponse()
         {
             StatusCode = httpStatusCode
         });
     });
 }
Пример #4
0
 public TestContext(FakeHttpApplication fakeHttpApplication)
 {
     App = fakeHttpApplication;
 }
Пример #5
0
 public FakeHttpRequest(FakeHttpApplication httpApplication)
 {
     _httpApplication = httpApplication ?? throw new ArgumentNullException(nameof(httpApplication));
 }
Пример #6
0
 public FakeHttpContext(FakeHttpApplication fakeHttpApplication)
 {
     _fakeHttpApplication = fakeHttpApplication ?? throw new ArgumentNullException(nameof(fakeHttpApplication));
     Items = new Hashtable();
 }
Пример #7
0
 public FakeHttpServerUtility(FakeHttpApplication httpApplication)
 {
     _httpApplication = httpApplication ?? throw new ArgumentNullException(nameof(httpApplication));
 }