Exemplo n.º 1
0
        public void ProcessRequestInvokes()
        {
            ServerConfig          config = new ServerConfig();
            ServerConfig_Accessor a      = ServerConfig_Accessor.AttachShadow(config);

            ServerConfig_Accessor.m_instance = config;

            XmlDocument d = new XmlDocument();

            d.LoadXml(string.Format("<restServices><Assemblies><add name=\"{0}\" /></Assemblies></restServices>", this.GetType().Assembly.GetName().Name));
            RestConfig_Accessor restConfig = new RestConfig_Accessor(d);

            a.Rest = restConfig;

            IHttpHandler         target = new RestHandler();
            RestHandler_Accessor ra     = RestHandler_Accessor.AttachShadow(target);


            HttpWorkerRequestMock r = new HttpWorkerRequestMock();

            r.HttpVerb = "GET";
            r.UriPath  = "/directory/path/blah";
            HttpContext          context = new HttpContext(r, true);
            HttpContext_Accessor hca     = HttpContext_Accessor.AttachShadow(context);

            RestServiceMock.Clear();
            target.ProcessRequest(context);
            Assert.IsTrue(RestServiceMock.Instantiated);
            MethodInfo expected = typeof(RestServiceMock).GetMethod("GetSomething");

            Assert.AreEqual(expected, RestServiceMock.Invoked);
        }
Exemplo n.º 2
0
        public void GetMethodForRequest()
        {
            ServerConfig          config = new ServerConfig();
            ServerConfig_Accessor a      = ServerConfig_Accessor.AttachShadow(config);

            ServerConfig_Accessor.m_instance = config;

            XmlDocument d = new XmlDocument();

            d.LoadXml(string.Format("<restServices><Assemblies><add name=\"{0}\" /></Assemblies></restServices>", this.GetType().Assembly.GetName().Name));
            RestConfig_Accessor restConfig = new RestConfig_Accessor(d);

            a.Rest = restConfig;

            RestHandler          target = new RestHandler();
            RestHandler_Accessor ra     = RestHandler_Accessor.AttachShadow(target);

            MethodInfo m        = ra.GetMethodForRequest("/directory/path/blah", HttpMethod.GET);
            MethodInfo expected = typeof(RestServiceMock).GetMethod("GetSomething");

            Assert.IsNotNull(m);
            Assert.AreEqual(expected, m);
        }