I’m looking for some general advice with an API framework I am setting up using C# and as the client library. I’ve successfully set up an initial test, but I’m now looking at creating a series of assertions to ensure that certain values are returned in the

My test looks as below:

    public void ShouldHaveDataAttributes()
        var restClient = new RestClient("http://ergast.com/api/f1");

        var restRequest = new RestRequest("2016/circuits.", Method.GET);

        var restResponse = restClient.Execute(restRequest);

        dynamic jsonResponse = JsonConvert.DeserializeObject(restResponse.Content);

        dynamic jsonObject = jsonResponse.MRData.CircuitTable;
        int circuitId = (int)jsonObject.season;

The jsonObject returns the below data:

  "season": "2016",
  "Circuits": [
      "circuitId": "albert_park",
      "url": "http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit",
      "circuitName": "Albert Park Grand Prix Circuit",
      "Location": {
        "lat": "-37.8497",
        "long": "144.968",
        "locality": "Melbourne",
        "country": "Australia"

My question is how would I specifically check that, for example the correct “circuitId” is returned or that the “circuitName” value is “Albert Park”? I’m keen to carry on utilising RestSharp for my framework so was hoping there was an extension to allow me to do that

Source link https://sqa.stackexchange.com/questions/35532/-json-response-using-restsharp


Please enter your comment!
Please enter your name here