本文整理汇总了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());
}
示例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());
}
示例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));
}
示例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));
}
示例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());
}
示例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);
}
示例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>());
}