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


C# Api.GetAsync方法代码示例

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


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

示例1: Repository_Authority_AllAuthorities_Returns_All

 public async Task Repository_Authority_AllAuthorities_Returns_All()
 {
     var api = new Api<AuthoritiesViewModel>(new Mock<ILog>().Object);
     var result = await api.GetAsync("Authorities", string.Empty);
     Assert.IsNotNull(result);
     Assert.That(result.Authorities.Any());
 }
开发者ID:rg911,项目名称:Free-API-Consumer,代码行数:7,代码来源:AuthorityModelTest.cs

示例2: Repository_Establishments_AllAuthorities_Returns_All

 public async Task Repository_Establishments_AllAuthorities_Returns_All()
 {
     var api = new Api<EstablishmentsViewModel>(new Mock<ILog>().Object);
     var result = await api.GetAsync("Establishments?LocalAuthorityId=197", string.Empty);
     Assert.IsNotNull(result);
     Assert.That(result.Establishments.Any());
 }
开发者ID:rg911,项目名称:Free-API-Consumer,代码行数:7,代码来源:EstablishmentsModelTest.cs

示例3: Repository_Establishments_Single_Return_One_Record

 public async Task Repository_Establishments_Single_Return_One_Record()
 {
     var api = new Api<EstablishmentsModel>(new Mock<ILog>().Object);
     var result = await api.GetAsync("Establishments/1", string.Empty);
     Assert.IsNotNull(result);
     Assert.That(!string.IsNullOrEmpty(result.RatingValue));
 }
开发者ID:rg911,项目名称:Free-API-Consumer,代码行数:7,代码来源:EstablishmentsModelTest.cs

示例4: Repository_Authority_Single_Return_One_Record

 public async Task Repository_Authority_Single_Return_One_Record()
 {
     var api = new Api<AuthorityModel>(new Mock<ILog>().Object);
     var result = await api.GetAsync("Authorities/197", string.Empty);
     Assert.IsNotNull(result);
     Assert.That(result.Id == 197);
     Assert.That(!string.IsNullOrEmpty(result.Name));
     Assert.That(!string.IsNullOrEmpty(result.RegionName));
 }
开发者ID:rg911,项目名称:Free-API-Consumer,代码行数:9,代码来源:AuthorityModelTest.cs

示例5: Repository_Establishments_GetRating_Returns_All

 public async Task Repository_Establishments_GetRating_Returns_All()
 {
     var apiService = new Api<EstablishmentsViewModel>(new Mock<ILog>().Object);
     var model = await apiService.GetAsync("Establishments?LocalAuthorityId=197", string.Empty);
     var restultEs = model.Establishments.GroupBy(x => x.RatingValue).Select(group=> new { RateValue = group.Key, Count = group.Count() }).OrderBy(x=>x.RateValue).ToList();
     var result = restultEs.Select(x => new RatingViewModel() { RatingName = x.RateValue, Percentage = (decimal)x.Count / model.Establishments.Count() })
          .ToList();
     Assert.IsNotNull(result);
     Assert.That(result.Any());
     Assert.IsNotNull(result.Select(x=>x.RatingName).FirstOrDefault());
     Assert.IsNotNull(result.Select(x => x.Percentage).FirstOrDefault());
 }
开发者ID:rg911,项目名称:Free-API-Consumer,代码行数:12,代码来源:EstablishmentsModelTest.cs

示例6: Api_GetAsync_Invalid_Json_Response_Throw_NotAcceptableException

 public void Api_GetAsync_Invalid_Json_Response_Throw_NotAcceptableException()
 {
     var api = new Api<EmtpyTestClass>(new Mock<ILog>().Object) {BaseApiUrl = "http://www.google.co.uk/"};
     Assert.That(() => api.GetAsync("AnyUri", string.Empty), Throws.TypeOf<HttpRequestException>().And.Not.Message.Empty);
 }
开发者ID:rg911,项目名称:Free-API-Consumer,代码行数:5,代码来源:ApiTest.cs

示例7: Api_GetAsync_Invalid_Url_Throw_HttpRequestException

 public void Api_GetAsync_Invalid_Url_Throw_HttpRequestException()
 {
     var api = new Api<EmtpyTestClass>(new Mock<ILog>().Object) {BaseApiUrl = "http://testWrongUri"};
     Assert.That(() => api.GetAsync("AnyUri", string.Empty), Throws.TypeOf<HttpRequestException>());
     Assert.That(() => api.GetAsync("AnyUri", string.Empty), Throws.TypeOf<HttpRequestException>());
 }
开发者ID:rg911,项目名称:Free-API-Consumer,代码行数:6,代码来源:ApiTest.cs


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