protected async Task <object> TestPost(ITestClient client, string apiUrl, string[] expectedFields, Dictionary <string, object> payload, bool verifyWithGet = false, string identifierName = "id") { //only perform get if explicitly requested var getResponse = verifyWithGet ? await TestGet(client, apiUrl, expectedFields) : null; var newTaskTemplateResponse = await client.PostAsync(apiUrl, payload); var newObject = AssertHelper.AssertObject(newTaskTemplateResponse, expectedFields); //check with second get if really added to list if (getResponse != null) { //check more elements returned var getResponse2 = await TestGet(client, apiUrl, expectedFields); AssertHelper.AssertArrayDifference(getResponse, getResponse2, 1); //check added element returned await EnsureObjectExists(client, apiUrl, expectedFields, identifierName, (int)newObject[identifierName], payload); } return(newTaskTemplateResponse); }
public async Task <IActionResult> GetAsync() { var result = await _client.PostAsync(); return(Ok(result)); }