Example #1
0
 public void SetRequest( MvcRequest req ) {
     CurrentRequest.setRequest( req );
 }
Example #2
0
        public static MockWebContext New( int userId, String httpMethod, String url, StringWriter sw )
        {
            // 构造request/response/httpContext
            MvcRequest req = new MvcRequest( url );
            req.HttpMethod = strUtil.IsNullOrEmpty( httpMethod ) ? "GET" : httpMethod;

            MvcResponse res = new MvcResponse();
            res.Writer = sw;

            MvcHttpContext ctx = new MvcHttpContext();
            ctx.Request = req;
            ctx.Response = res;

            // 同时构造静态context
            CurrentRequest.setRequest( req );

            MockWebContext mctx = new MockWebContext( ctx );
            mctx.setUserId( userId );

            return mctx;
        }
Example #3
0
 //public IDictionary items;
 //private String rawUrl;
 //public String[] userLanguages;
 //public String httpMethod;
 //public NameValueCollection form;
 public static void setRequest( MvcRequest req )
 {
     if (req == null) {
         setItem( "_RawUrl", null );
         setItem( "_UserLanguages", null );
         setItem( "_HttpMethod", null );
         setItem( "_Form", null );
     }
     else {
         setItem( "_RawUrl", req.RawUrl );
         setItem( "_UserLanguages", req.UserLanguages );
         setItem( "_HttpMethod", req.HttpMethod );
         setItem( "_Form", req.Form );
     }
 }