2016-08-09 209 views
1

I API-Tests schreibe mit VS & C#API-Test in C# - Wie vergleiche ich die gesamte JSON-Antwort in 1 Assertion?

Ich habe einen Test, der wie folgt aussieht:

[TestCase("buddy")] 
public void CreatePet(string name) 
{ 
    //Setup Request 
    RestRequest = new RestRequest("pet", Method.POST); 

    //Load JSON File 
    string RequestBody = Utils.LoadJson("CreatePet.json"); 
    RestRequest.AddParameter("application/json", RequestBody, ParameterType.RequestBody); 

    //Call REST Resource 
    ResponseJSON = JSON_NET_GetResponse(RestRequest); 

    //Verify Response JSON 
    ((string) ResponseJSON.name).Should().Be("doggie"); 
    ((string) ResponseJSON.status).Should().Be("available"); 
    ((Int64) ResponseJSON.id).Should().BeGreaterThan(Int32.MaxValue); 
    ((string) ResponseJSON.tags[0].name).Should().Be("string"); 
    ((int) ResponseJSON.tags.Count