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


C# IRestClient.Get方法代码示例

本文整理汇总了C#中IRestClient.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IRestClient.Get方法的具体用法?C# IRestClient.Get怎么用?C# IRestClient.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRestClient的用法示例。


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

示例1: Get_empty_request_throws_validation_exception

        public void Get_empty_request_throws_validation_exception(IRestClient client)
        {
            try
            {
                var response = client.Get<CustomersResponse>("/Customers");
                Assert.Fail("Should throw Validation Exception");
            }
            catch (WebServiceException ex)
            {
                var response = (CustomersResponse)ex.ResponseDto;

                var errorFields = response.ResponseStatus.Errors;
                Assert.That(ex.StatusCode, Is.EqualTo((int)HttpStatusCode.BadRequest));
                Assert.That(errorFields.Count, Is.EqualTo(1));
                Assert.That(errorFields[0].ErrorCode, Is.EqualTo("NotEqual"));
                Assert.That(errorFields[0].FieldName, Is.EqualTo("Id"));
            }
        }
开发者ID:austinvernsonger,项目名称:ServiceStack,代码行数:18,代码来源:CustomerServiceValidationTests.cs

示例2: Get_empty_request_throws_validation_exception

        public void Get_empty_request_throws_validation_exception(IRestClient client)
        {
            try
            {
                var response = client.Get(new Customers());
                response.PrintDump();
                Assert.Fail("Should throw Validation Exception");
            }
            catch (WebServiceException ex)
            {
                var response = (CustomersResponse)ex.ResponseDto;

                var errorFields = response.ResponseStatus.Errors;
                Assert.That(ex.StatusCode, Is.EqualTo((int)HttpStatusCode.BadRequest));
                //Assert.That(ex.StatusDescription, Is.EqualTo("NotEqual")); //BadRequest
                Assert.That(response.ResponseStatus.Message, Is.EqualTo("'Id' should not be equal to '0'."));
                Assert.That(errorFields.Count, Is.EqualTo(1));
                Assert.That(errorFields[0].ErrorCode, Is.EqualTo("NotEqual"));
                Assert.That(errorFields[0].FieldName, Is.EqualTo("Id"));
                Assert.That(errorFields[0].Message, Is.EqualTo("'Id' should not be equal to '0'."));
            }
        }
开发者ID:HarmenGrosseDeters,项目名称:ServiceStack,代码行数:22,代码来源:CustomerServiceValidationTests.cs

示例3: Sync_Call_HelloWorld_with_RestClients_on_UserDefined_Routes

        public void Sync_Call_HelloWorld_with_RestClients_on_UserDefined_Routes(IRestClient client)
        {
            var response = client.Get<HelloResponse>("/hello/World!");

            Assert.That(response.Result, Is.EqualTo("Hello, World!"));
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:6,代码来源:HelloWorldServiceClientTests.cs


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