private static void DoBasicCommTest(string controller, bool doReverse = true)
        {
            var client = new ProtoBufWebClient();

            var response = client.SendRequest <SampleModel>(new ProtoRequest(GetUri(string.Empty, controller), null, "GET"));

            Assert.IsNotNull(response);
            Assert.AreEqual("testVal", response.StringProp);
            Assert.IsNotNull(response.SubComplex1);
            Assert.AreEqual(2, response.SubComplex1.IntProp);

            var responseHeaders = client.ResponseHeaders;

            AssertResponseHeaders(responseHeaders);

            var contentType = GetContentType(responseHeaders);

            AssertContentType(RestfulServiceConstants.ProtoContentType, contentType);

            if (doReverse)
            {
                var resp2 = client.SendRequest <string>(new ProtoRequest(GetUri("Reverse", controller), response, "POST"));

                responseHeaders = client.ResponseHeaders;

                AssertResponseHeaders(responseHeaders);

                contentType = GetContentType(responseHeaders);

                AssertContentType(RestfulServiceConstants.ProtoContentType, contentType);

                Assert.AreEqual("ok", resp2);
            }
        }
Example #2
0
        private static void DoBasicCommTest(string controller, bool doReverse = true)
        {
            var client = new ProtoBufWebClient();

            var response = client.SendRequest<SampleModel>(new ProtoRequest(GetUri(string.Empty, controller), null, "GET"));

            Assert.IsNotNull(response);
            Assert.AreEqual("testVal", response.StringProp);
            Assert.IsNotNull(response.SubComplex1);
            Assert.AreEqual(2, response.SubComplex1.IntProp);

            var responseHeaders = client.ResponseHeaders;

            AssertResponseHeaders(responseHeaders);

            var contentType = GetContentType(responseHeaders);

            AssertContentType(RestfulServiceConstants.ProtoContentType, contentType);

            if (doReverse)
            {
                var resp2 = client.SendRequest<string>(new ProtoRequest(GetUri("Reverse", controller), response, "POST"));

                responseHeaders = client.ResponseHeaders;

                AssertResponseHeaders(responseHeaders);

                contentType = GetContentType(responseHeaders);

                AssertContentType(RestfulServiceConstants.ProtoContentType, contentType);

                Assert.AreEqual("ok", resp2);
            }
        }
        public void ListTest()
        {
            var client = new ProtoBufWebClient();

            var response = client.SendRequest <List <SampleModel> >(
                new ProtoRequest(GetUri("getlist"), null, "GET")
            {
                RequestHeaders = new Dictionary <string, string>()
                {
                    { "accept-encoding", "gzip" }
                }
            });

            Assert.IsNotNull(response);

            const int resultCount = 10000;

            Assert.AreEqual(resultCount, response.Count);

            for (int i = 0; i < resultCount; i++)
            {
                Assert.AreEqual(i.GetHashCode().ToString(CultureInfo.InvariantCulture), response[i].StringProp);
                Assert.IsNotNull(response[i].SubComplex1);
                Assert.AreEqual(i, response[i].SubComplex1.IntProp);
            }

            var responseHeaders = client.ResponseHeaders;

            AssertResponseHeaders(responseHeaders);

            var contentType = GetContentType(responseHeaders);

            AssertContentType(RestfulServiceConstants.ProtoContentType, contentType);
        }
Example #4
0
        public void ListTest()
        {
            var client = new ProtoBufWebClient();
 
            var response = client.SendRequest<List<SampleModel>>(
                new ProtoRequest(GetUri("getlist"), null, "GET")
                    {
                        RequestHeaders = new Dictionary<string, string>()
                                             {
                                                 {"accept-encoding", "gzip"}
                                             }
                    });

            Assert.IsNotNull(response);

            const int resultCount = 10000;

            Assert.AreEqual(resultCount, response.Count);

            for (int i = 0; i < resultCount; i++)
            {
                Assert.AreEqual(i.GetHashCode().ToString(CultureInfo.InvariantCulture), response[i].StringProp);
                Assert.IsNotNull(response[i].SubComplex1);
                Assert.AreEqual(i, response[i].SubComplex1.IntProp);
            }

            var responseHeaders = client.ResponseHeaders;

            AssertResponseHeaders(responseHeaders);

            var contentType = GetContentType(responseHeaders);

            AssertContentType(RestfulServiceConstants.ProtoContentType, contentType);
        }