Exemple #1
0
        public async Task Request_Deserialize_Serialize()
        {
            var stream     = Assembly.GetExecutingAssembly().GetManifestResourceStream("CacheCow.Client.Tests.Data.Request.cs");
            var serializer = new MessageContentHttpMessageSerializer();
            var request    = await serializer.DeserializeToRequestAsync(stream);

            var memoryStream = new MemoryStream();
            await serializer.SerializeAsync(request, memoryStream);

            memoryStream.Position = 0;
            var request2 = await serializer.DeserializeToRequestAsync(memoryStream);

            var result = DeepComparer.Compare(request, request2);
        }
        public async Task Request_Deserialize_Serialize()
        {
            var stream     = Assembly.GetExecutingAssembly().GetManifestResourceStream("CacheCow.Client.Tests.Data.Request.cs");
            var serializer = new MessageContentHttpMessageSerializer();
            var request    = await serializer.DeserializeToRequestAsync(stream);

            var memoryStream = new MemoryStream();
            await serializer.SerializeAsync(request, memoryStream);

            memoryStream.Position = 0;
            var request2 = await serializer.DeserializeToRequestAsync(memoryStream);

            var result = DeepComparer.Compare(request, request2);

            // !! Ignore this until RTM since this is fixed. See http://aspnetwebstack.codeplex.com/workitem/303
            //if (result.Count() > 0)
            //Assert.Fail(string.Join("\r\n", result));
        }
        public async Task Response_Deserialize_Serialize()
        {
            var stream     = Assembly.GetExecutingAssembly().GetManifestResourceStream("CacheCow.Client.Tests.Data.Response.cs");
            var serializer = new MessageContentHttpMessageSerializer();
            var response   = await serializer.DeserializeToResponseAsync(stream);

            var memoryStream = new MemoryStream();
            await serializer.SerializeAsync(response, memoryStream);

            memoryStream.Position = 0;
            var response2 = await serializer.DeserializeToResponseAsync(memoryStream);

            var result = DeepComparer.Compare(response, response2);

            if (result.Count() > 0)
            {
                throw new Exception(string.Join("\r\n", result));
            }
        }
Exemple #4
0
        public void Response_Deserialize_Serialize_File()
        {
            var stream     = Assembly.GetExecutingAssembly().GetManifestResourceStream("CacheCow.Client.Tests.Data.Response.cs");
            var serializer = new MessageContentHttpMessageSerializer();
            var response   = serializer.DeserializeToResponseAsync(stream).Result;

            using (var fileStream = new FileStream("response.tmp", FileMode.Create))
            {
                serializer.SerializeAsync(TaskHelpers.FromResult(response), fileStream).Wait();

                fileStream.Position = 0;
                var response2 = serializer.DeserializeToResponseAsync(fileStream).Result;
                var result    = DeepComparer.Compare(response, response2);
                if (result.Count() > 0)
                {
                    Assert.Fail(string.Join("\r\n", result));
                }
            }
        }
        public async Task Response_Deserialize_Serialize_File()
        {
            var stream     = Assembly.GetExecutingAssembly().GetManifestResourceStream("CacheCow.Client.Tests.Data.Response.cs");
            var serializer = new MessageContentHttpMessageSerializer();
            var response   = await serializer.DeserializeToResponseAsync(stream);

            using (var fileStream = new FileStream(Path.GetTempFileName(), FileMode.Create))
            {
                await serializer.SerializeAsync(response, fileStream);

                fileStream.Position = 0;
                var response2 = await serializer.DeserializeToResponseAsync(fileStream);

                var result = DeepComparer.Compare(response, response2);
                if (result.Count() > 0)
                {
                    throw new Exception(string.Join("\r\n", result));
                }
            }
        }
Exemple #6
0
        public async Task Response_Deserialize_Serialize()
        {
            using (var stream = new FileStream("Data/Response.cs", FileMode.Open))
            {
                var serializer = new MessageContentHttpMessageSerializer();
                var response   = await serializer.DeserializeToResponseAsync(stream);

                var memoryStream = new MemoryStream();
                await serializer.SerializeAsync(response, memoryStream);

                memoryStream.Position = 0;
                var response2 = await serializer.DeserializeToResponseAsync(memoryStream);

                var result = DeepComparer.Compare(response, response2);
                if (result.Count() > 0)
                {
                    throw new Exception(string.Join("\r\n", result));
                }
            }
        }
Exemple #7
0
        public async Task Response_Deserialize_Serialize_File()
        {
            using (var stream = new FileStream("Data/Response.cs", FileMode.Open))
            {
                var serializer = new MessageContentHttpMessageSerializer();
                var response   = await serializer.DeserializeToResponseAsync(stream);

                using (var fileStream = new FileStream(Path.GetTempFileName(), FileMode.Create))
                {
                    await serializer.SerializeAsync(response, fileStream);

                    fileStream.Position = 0;
                    var response2 = await serializer.DeserializeToResponseAsync(fileStream);

                    var result = DeepComparer.Compare(response, response2);
                    if (result.Count() > 0)
                    {
                        throw new Exception(string.Join("\r\n", result));
                    }
                }
            }
        }