当前位置: 首页>>代码示例>>C#>>正文


C# RestResponse类代码示例

本文整理汇总了C#中RestResponse的典型用法代码示例。如果您正苦于以下问题:C# RestResponse类的具体用法?C# RestResponse怎么用?C# RestResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RestResponse类属于命名空间,在下文中一共展示了RestResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Can_Deserialize_Attributes_Without_Matching_Case_On_Default_Root

        public void Can_Deserialize_Attributes_Without_Matching_Case_On_Default_Root()
        {
            var doc = CreateLowercaseDashesXml();
            var response = new RestResponse { Content = doc };

            var d = new XmlDeserializer();
            var p = d.Deserialize<PersonForXml>(response);

            Assert.Equal("John Sheehan", p.Name);
            Assert.Equal(new DateTime(2009, 9, 25, 0, 6, 1), p.StartDate);
            Assert.Equal(28, p.Age);
            Assert.Equal(long.MaxValue, p.BigNumber);
            Assert.Equal(99.9999m, p.Percent);
            Assert.Equal(false, p.IsCool);
            Assert.Equal(new Guid(GuidString), p.UniqueId);
            Assert.Equal(new Uri("http://example.com", UriKind.RelativeOrAbsolute), p.Url);
            Assert.Equal(new Uri("/foo/bar", UriKind.RelativeOrAbsolute), p.UrlPath);

            Assert.NotNull(p.Friends);
            Assert.Equal(10, p.Friends.Count);

            Assert.NotNull(p.BestFriend);
            Assert.Equal("The Fonz", p.BestFriend.Name);
            Assert.Equal(1952, p.BestFriend.Since);

            Assert.NotNull(p.Foes);
            Assert.Equal(5, p.Foes.Count);
            Assert.Equal("Yankees", p.Foes.Team);
        }
开发者ID:florinn,项目名称:RestSharp,代码行数:29,代码来源:XmlTests.cs

示例2: Can_Deserialize_Elements_With_Namespace

        public void Can_Deserialize_Elements_With_Namespace()
        {
            var doc = CreateElementsXml();

            var response = new RestResponse { Content = doc };

            var d = new XmlDeserializer();
            d.Namespace = "http://restsharp.org";
            var p = d.Deserialize<PersonForXml>(response);

            Assert.Equal("John Sheehan", p.Name);
            Assert.Equal(new DateTime(2009, 9, 25, 0, 6, 1), p.StartDate);
            Assert.Equal(28, p.Age);
            Assert.Equal(long.MaxValue, p.BigNumber);
            Assert.Equal(99.9999m, p.Percent);
            Assert.Equal(false, p.IsCool);
            Assert.Equal(new Guid(GuidString), p.UniqueId);
            Assert.Equal(new Uri("http://example.com", UriKind.RelativeOrAbsolute), p.Url);
            Assert.Equal(new Uri("/foo/bar", UriKind.RelativeOrAbsolute), p.UrlPath);

            Assert.NotNull(p.Friends);
            Assert.Equal(10, p.Friends.Count);

            Assert.NotNull(p.BestFriend);
            Assert.Equal("The Fonz", p.BestFriend.Name);
            Assert.Equal(1952, p.BestFriend.Since);
        }
开发者ID:khasan,项目名称:RestSharp,代码行数:27,代码来源:NamespacedXmlTests.cs

示例3: Can_deserialize_to_dynamic_collection

 public void Can_deserialize_to_dynamic_collection()
 {
     var serializer = new JsonSerializer();
     var response = new RestResponse<JsonObject>();
     response.SetContent(DoubleInput);
     var proxy = serializer.DeserializeDynamic(response);
     Assert.IsNotNull(proxy);
 }
开发者ID:pcl,项目名称:hammock,代码行数:8,代码来源:SerializationTests.cs

示例4: Can_deserialize_to_dynamic_single

 public void Can_deserialize_to_dynamic_single()
 {
     var serializer = new DefaultJsonSerializer();
     var response = new RestResponse<dynamic>();
     response.SetContent(SingleInput);
     var proxy = serializer.DeserializeDynamic(response);
     Assert.IsNotNull(proxy);
 }
开发者ID:pcl,项目名称:hammock,代码行数:8,代码来源:SerializationTests.cs

示例5: Can_Deserialize_AcoustID_Xml

        public void Can_Deserialize_AcoustID_Xml()
        {
            var xmlpath = PathFor("AcoustID.xml");
            var doc = XDocument.Load(xmlpath);
            var response = new RestResponse { Content = doc.ToString() };

            var d = new XmlDeserializer();
            var output = d.Deserialize<MTB.Worker.AcoustID.Response>(response);
        }
开发者ID:BerndK,项目名称:RestSharp,代码行数:9,代码来源:XmlTests.cs

示例6: Can_Deserialize_DateTime

        public void Can_Deserialize_DateTime()
        {
            var doc = File.ReadAllText(Path.Combine("SampleData", "datetimes.txt"));
            var d = new JsonDeserializer();
            var response = new RestResponse { Content = doc };
            var payload = d.Deserialize<DateTimeTestStructure>(response);

            Assert.Equal(
                new DateTime(2011, 6, 30, 8, 15, 46, DateTimeKind.Utc).ToString("u"),
                payload.DateTime.ToString("u"));
        }
开发者ID:89sos98,项目名称:RestSharp,代码行数:11,代码来源:JsonTests.cs

示例7: Can_Deserialize_Boolean_From_Number

        public void Can_Deserialize_Boolean_From_Number()
        {
            var xmlpath = PathFor("boolean_from_number.xml");
                var doc = XDocument.Load(xmlpath);
                var response = new RestResponse { Content = doc.ToString() };

                var d = new XmlDeserializer();
                var output = d.Deserialize<SampleClasses.BooleanTest>(response);

                Assert.True(output.Value);
        }
开发者ID:ntziolis,项目名称:RestSharp,代码行数:11,代码来源:XmlTests.cs

示例8: Can_deserialize_all_test_cases

        public void Can_deserialize_all_test_cases()
        {
            var serializer = new DefaultJsonSerializer();
            var files = Directory.GetFiles("Json", "*.json");
            foreach(var file in files)
            {
                var json = File.ReadAllText(file);
                var response = new RestResponse<dynamic>();
                response.SetContent(json);

                var proxy = serializer.DeserializeDynamic(response);
                Assert.IsNotNull(proxy);
            }
        }
开发者ID:pcl,项目名称:hammock,代码行数:14,代码来源:SerializationTests.cs

示例9: Can_Deserialize_Custom_Formatted_Date

        public void Can_Deserialize_Custom_Formatted_Date()
        {
            var format = "dd yyyy MMM, hh:mm ss tt";
            var date = new DateTime(2010, 2, 8, 11, 11, 11);

            var formatted = new {
                StartDate = date.ToString(format)
            };

            var data = JsonConvert.SerializeObject(formatted);
            var response = new RestResponse { Content = data };

            var json = new JsonDeserializer { DateFormat = format };

            var output = json.Deserialize<PersonForJson>(response);

            Assert.Equal(date, output.StartDate);
        }
开发者ID:geoffreysimpson,项目名称:RestSharp,代码行数:18,代码来源:JsonTests.cs

示例10: Can_Deserialize_Attributes_With_Namespace

        public void Can_Deserialize_Attributes_With_Namespace()
        {
            string doc = CreateAttributesXml();
            RestResponse response = new RestResponse { Content = doc };
            XmlDeserializer d = new XmlDeserializer { Namespace = "http://restsharp.org" };
            PersonForXml p = d.Deserialize<PersonForXml>(response);

            Assert.AreEqual("John Sheehan", p.Name);
            Assert.AreEqual(new DateTime(2009, 9, 25, 0, 6, 1), p.StartDate);
            Assert.AreEqual(28, p.Age);
            Assert.AreEqual(long.MaxValue, p.BigNumber);
            Assert.AreEqual(99.9999m, p.Percent);
            Assert.AreEqual(false, p.IsCool);
            Assert.AreEqual(new Guid(GUID_STRING), p.UniqueId);
            Assert.AreEqual(new Uri("http://example.com", UriKind.RelativeOrAbsolute), p.Url);
            Assert.AreEqual(new Uri("/foo/bar", UriKind.RelativeOrAbsolute), p.UrlPath);
            Assert.NotNull(p.BestFriend);
            Assert.AreEqual("The Fonz", p.BestFriend.Name);
            Assert.AreEqual(1952, p.BestFriend.Since);
        }
开发者ID:CL0SeY,项目名称:RestSharp,代码行数:20,代码来源:NamespacedXmlTests.cs

示例11: Can_Deserialize_Attributes_On_Default_Root

        public void Can_Deserialize_Attributes_On_Default_Root()
        {
            var doc = CreateAttributesXml();
            var response = new RestResponse { Content = doc };

            var d = new XmlDeserializer();
            var p = d.Deserialize<PersonForXml>(response);

            Assert.Equal("John Sheehan", p.Name);
            Assert.Equal(new DateTime(2009, 9, 25, 0, 6, 1), p.StartDate);
            Assert.Equal(28, p.Age);
            Assert.Equal(long.MaxValue, p.BigNumber);
            Assert.Equal(99.9999m, p.Percent);
            Assert.Equal(false, p.IsCool);
            Assert.Equal(new Guid(GuidString), p.UniqueId);

            Assert.NotNull(p.BestFriend);
            Assert.Equal("The Fonz", p.BestFriend.Name);
            Assert.Equal(1952, p.BestFriend.Since);
        }
开发者ID:geoffreysimpson,项目名称:RestSharp,代码行数:20,代码来源:XmlTests.cs

示例12: Can_Deserialize_Custom_Formatted_Date

        public void Can_Deserialize_Custom_Formatted_Date()
        {
            var format = "dd yyyy MMM, hh:mm ss tt zzz";
            var date = new DateTime(2010, 2, 8, 11, 11, 11);

            var doc = new XDocument();

            var root = new XElement("Person");
            root.Add(new XElement("StartDate", date.ToString(format)));

            doc.Add(root);

            var xml = new XmlDeserializer();
            xml.DateFormat = format;

            var response = new RestResponse { Content = doc.ToString() };
            var output = xml.Deserialize<PersonForXml>(response);

            Assert.Equal(date, output.StartDate);
        }
开发者ID:khasan,项目名称:RestSharp,代码行数:20,代码来源:XmlTests.cs

示例13: Can_Deserialize_Unix_Json_Dates

        public void Can_Deserialize_Unix_Json_Dates()
        {
            var doc = CreateUnixDateJson();
            var d = new JsonDeserializer();
            var response = new RestResponse { Content = doc };
            var bd = d.Deserialize<Birthdate>(response);

            Assert.Equal(new DateTime(2011, 6, 30, 8, 15, 46, DateTimeKind.Utc), bd.Value);
        }
开发者ID:t9mike,项目名称:RestSharp,代码行数:9,代码来源:JsonTests.cs

示例14: Can_Deserialize_To_Dictionary_String_String

        public void Can_Deserialize_To_Dictionary_String_String()
        {
            var doc = CreateJsonStringDictionary();
            var d = new JsonDeserializer();
            var response = new RestResponse { Content = doc };
            var bd = d.Deserialize<Dictionary<string,string>>(response);

            Assert.Equal(bd["Thing1"], "Thing1");
            Assert.Equal(bd["Thing2"], "Thing2");
            Assert.Equal(bd["ThingRed"], "ThingRed");
            Assert.Equal(bd["ThingBlue"], "ThingBlue");
        }
开发者ID:t9mike,项目名称:RestSharp,代码行数:12,代码来源:JsonTests.cs

示例15: Can_Deserialize_To_Dictionary_String_String_With_Dynamic_Values

        public void Can_Deserialize_To_Dictionary_String_String_With_Dynamic_Values()
        {
            var doc = CreateDynamicJsonStringDictionary ();
            var d = new JsonDeserializer ();
            var response = new RestResponse { Content = doc };
            var bd = d.Deserialize<Dictionary<string, string>> (response);

            Assert.Equal ("[\"Value1\",\"Value2\"]", bd["Thing1"]);
            Assert.Equal ("Thing2", bd["Thing2"]);
            Assert.Equal ("{\"Name\":\"ThingRed\",\"Color\":\"Red\"}", bd["ThingRed"]);
            Assert.Equal ("{\"Name\":\"ThingBlue\",\"Color\":\"Blue\"}", bd["ThingBlue"]);
        }
开发者ID:t9mike,项目名称:RestSharp,代码行数:12,代码来源:JsonTests.cs


注:本文中的RestResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。