public void Can_deserialize_TestRequest_QueryStringSerializer_output()
        {
            // Setup
            new BasicAppHost(new Container(), typeof(TestService).Assembly).Init();
            var restPath = new RestPath(typeof(TestRequest), "/service", "GET");
            var restHandler = new RestHandler { RestPath = restPath };

            var requestString = "ListOfA={ListOfB:[{Property:prop1},{Property:prop2}]}";
            NameValueCollection queryString = HttpUtility.ParseQueryString(requestString);
            var httpReq = new MockHttpRequest("service", "GET", "application/json", "service", queryString, new MemoryStream(), new NameValueCollection());

            var request2 = (TestRequest)restHandler.CreateRequest(httpReq, "service");

            Assert.That(request2.ListOfA.Count, Is.EqualTo(1));
            Assert.That(request2.ListOfA.First().ListOfB.Count, Is.EqualTo(2));
        }
 private T StringToPoco <T>(string str)
 {
     using (new BasicAppHost().Init())
     {
         NameValueCollection queryString = HttpUtility.ParseQueryString(str);
         var restPath    = new RestPath(typeof(T), "/query", "GET, POST");
         var restHandler = new RestHandler
         {
             RestPath = restPath
         };
         var httpReq = new MockHttpRequest("query", "GET", "application/json", "query", queryString,
                                           new MemoryStream(), new NameValueCollection());
         var request = (T)restHandler.CreateRequest(httpReq, "query");
         return(request);
     }
 }
Beispiel #3
0
        public void Can_deserialize_TestRequest_QueryStringSerializer_output()
        {
            // Setup
            var testAppHost = new TestAppHost(new Container(), typeof(TestService).Assembly);
            var restPath    = new RestPath(typeof(TestRequest), "/service", "GET");
            var restHandler = new RestHandler {
                RestPath = restPath
            };

            var requestString = "ListOfA={ListOfB:[{Property:prop1},{Property:prop2}]}";
            NameValueCollection queryString = HttpUtility.ParseQueryString(requestString);
            var httpReq = new HttpRequestMock("service", "GET", "application/json", "service", queryString, new MemoryStream(), new NameValueCollection());

            var request2 = (TestRequest)restHandler.CreateRequest(httpReq, "service");

            Assert.That(request2.ListOfA.Count, Is.EqualTo(1));
            Assert.That(request2.ListOfA.First().ListOfB.Count, Is.EqualTo(2));
        }