private static void CheckResponse(BrowserResponse response, string name, int age)
        {
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Equal(Constants.ProtoBufContentType, response.Context.Response.ContentType);
            Assert.IsType <ProtoBufResponse>(response.Context.Response);

            using (var memStream = new MemoryStream())
            {
                response.Context.Response.Contents(memStream);

                // try and deserialize the response body stream with protobuf
                memStream.Position = 0;
                var returnedUser = ProtoBufSerializer.Deserialize <User>(memStream);

                Assert.NotNull(returnedUser);
                Assert.Equal(name, returnedUser.Name);
                Assert.Equal(age, returnedUser.Age);
            }
        }
Example #2
0
        private static void CheckResponse(BrowserResponse response, string name, int age)
        {
            response.StatusCode.ShouldEqual(HttpStatusCode.OK);
            response.Context.Response.ContentType.ShouldEqual(Constants.ProtoBufContentType);
            response.Context.Response.ShouldBeOfType(typeof(ProtoBufResponse));

            using (var memStream = new MemoryStream())
            {
                response.Context.Response.Contents(memStream);

                // try and deserialize the response body stream with protobuf
                memStream.Position = 0;
                var returnedUser = ProtoBufSerializer.Deserialize <User>(memStream);

                returnedUser.ShouldNotBeNull();
                returnedUser.Name.ShouldEqual(name);
                returnedUser.Age.ShouldEqual(age);
            }
        }