public void Can_GET_SearchReqstars_PrettyRestApi(IRestClient client) { var request = new SearchReqstars(); var response = client.Get(request); Assert.That(request.ToUrl("GET"), Is.EqualTo("/reqstars/search")); Assert.That(response.Results.Count, Is.EqualTo(ReqstarsService.SeedData.Length)); }
public void Can_GET_SearchReqstars_aged_20_PrettyRestApi(IRestClient client) { var request = new SearchReqstars { Age = 20 }; var response = client.Get(request); Assert.That(request.ToUrl("GET"), Is.EqualTo("/reqstars/aged/20")); Assert.That(response.Results.Count, Is.EqualTo(ReqstarsService.SeedData.Count(x => x.Age == 20))); }
public object Get(SearchReqstars request) { return(new ReqstarsResponse //matches ReqstarsResponse.cshtml razor view { Aged = request.Age, Total = Db.GetScalar <int>("select count(*) from Reqstar"), Results = request.Age.HasValue ? Db.Select <Reqstar>(q => q.Age == request.Age.Value) : Db.Select <Reqstar>() }); }
public ReqstarsResponse Get(SearchReqstars request) { if (request.Age.HasValue && request.Age <= 0) { throw new ArgumentException("Invalid Age"); } return(new ReqstarsResponse //matches ReqstarsResponse.cshtml razor view { Aged = request.Age, Total = Db.Scalar <int>("select count(*) from Reqstar"), Results = request.Age.HasValue ? Db.Select <Reqstar>(q => q.Age == request.Age.Value) : Db.Select <Reqstar>() }); }