public void Can_Retrieve_Specific_Student() { int studentPicked; var ids = _studentDbContext.Students.Select(s => s.StudentId).ToArray(); int randomID = ids.OrderBy(x => Guid.NewGuid()).FirstOrDefault(); if (ids.Count() >= 1) { studentPicked = randomID; } else { throw new Exception("There is no data to test in DB"); } endPoint = _baseUrl + "/" + studentPicked; headers.Add("content-type", "application/json"); var result = API_Helper.GetRequest(endPoint, headers); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); var fromAPI = JsonConvert.DeserializeObject <Student>(result.Content); var fromDB = _studentDbContext.Students.Where(s => s.StudentId == randomID).ToList().FirstOrDefault(); Assert.IsTrue(fromAPI.stEquals(fromDB)); }
public void Can_Retrieve_All_Students() { endPoint = _baseUrl; headers.Add("content-type", "application/json"); var result = API_Helper.GetRequest(endPoint, headers); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); var fromAPI = JsonConvert.DeserializeObject <List <Student> >(result.Content).ToList(); var fromDB = _studentDbContext.Students.ToList(); Assert.IsTrue(API_Helper.Check3Spots(fromAPI, fromDB)); }