public void TCPost(string fn, string ln, string trusted) { Landlord lobj = new Landlord(fn, ln, trusted); string Landlorddata = JsonConvert.SerializeObject(lobj); IRestResponse Postresult = apiobj.Post(Landlorddata); IRestResponse getresult = apiobj.GetAll(); ArrayList ld = new ArrayList(); JArray lists = JArray.Parse(getresult.Content); int lng = lists.Count; // Console.Error.Write(lng); if (lng > 0) { lng = lng - 1; //Console.Error.Write(lng); // Console.Error.Write(lists[lng].ToString()); ld.Add(lists[lng].ToString()); int ldcount = ld.Count; // Console.Error.Write(ldcount); string Details = (string)ld[0]; //Console.Error.Write(ld[lng]); Landlord expected = JsonConvert.DeserializeObject <Landlord>(Details); Assert.AreEqual(expected.firstName, fn); Assert.AreEqual(expected.lastName, ln); Assert.AreEqual(expected.trusted, trusted); } }
public void TCGetDeleteAll() { IRestResponse getresult = apiobj.GetAll(); ArrayList ld = new ArrayList(); JArray lists = JArray.Parse(getresult.Content); for (int i = 0; i < lists.Count; i++) { ld.Add(lists[i].ToString()); string one = (string)ld[i]; Landlord expected = JsonConvert.DeserializeObject <Landlord>(one); IRestResponse DelResult = apiobj.DeletebyId(expected.id); // string Expect = DelResult.ResponseStatus; //string Actual= "{""message"/ : LandLord with id: " + expected.id+" successfully deleted}"; // Assert.AreSame(Expect, Actual); } IRestResponse getresult2 = apiobj.GetAll(); string Actres = getresult2.Content; Assert.AreEqual(Actres, "[]"); }