public void GetReviews_ReturnsList() { var dal = new ReviewsDAL(new Conn().AWSconnstring()); var list = dal.GetAllReviews(); Assert.True(list.Count > 1); }
public void DeleteTest_FailureReturnsObject() { var RC = new ReviewsController(connection); var review = new ReviewsDAL(connection.AWSconnstring()).GetAllReviews().LastOrDefault(); var result = RC.Delete(review.ReviewId + 100); Assert.IsType <StatusCodeResult>(result); }
public void DeleteTest_SuccessReturnsOK() { var RC = new ReviewsController(connection); var review = new ReviewsDAL(connection.AWSconnstring()).GetAllReviews().LastOrDefault(); var result = RC.Delete(review.ReviewId); Assert.IsType <OkResult>(result); }
public void DeletesReview_ReturnsTrue() { var dal = new ReviewsDAL(new Conn().AWSconnstring()); var review = dal.GetAllReviews().FirstOrDefault(); bool deleted = dal.DeleteReview(review.ReviewId); Assert.True(deleted); }
public void DeletesReview_LastIdChangedAfterDeletion() { var dal = new ReviewsDAL(new Conn().AWSconnstring()); var review = dal.GetAllReviews().FirstOrDefault(); dal.DeleteReview(review.ReviewId); var currentFirstReview = dal.GetAllReviews().FirstOrDefault(); Assert.True(!review.ReviewId.Equals(currentFirstReview.ReviewId)); }
public void UpdateReview_ReturnsTrue() { var dal = new ReviewsDAL(new Conn().AWSconnstring()); var review = dal.GetAllReviews().FirstOrDefault(); var updatedReview = new UpdateReview { ReviewId = review.ReviewId, ReviewText = "my updated text" }; bool updated = dal.UpdateReview(updatedReview).IsSuccessful; Assert.True(updated); }
public IActionResult Delete(int id) { bool IsSuccessful = new ReviewsDAL(connection.AWSconnstring()).DeleteReview(id); if (IsSuccessful) { return(Ok()); } else { return(StatusCode(404)); } }
public IActionResult Put([FromBody] UpdateReview updateReview) { var dal = new ReviewsDAL(connection.AWSconnstring()).UpdateReview(updateReview); if (dal.IsSuccessful) { return(Ok(dal.toreturn)); } else { return(StatusCode(304, dal.toreturn)); } }
public void PostReview_AddsNewReview() { var review = new PostReview { RestaurantId = 1, UserId = 2, ReviewText = "add this review. restaurant was great." }; var dal = new ReviewsDAL(new Conn().AWSconnstring()); var result = dal.PostReview(review); Assert.True(result.IsSuccessful); }
public IActionResult Get(string username) { var usermatch = new UserDAL(connection.AWSconnstring()).GetUser(username); if (!usermatch.IsSuccessful) { return(StatusCode(404, "User was not found")); } var list = new ReviewsDAL(connection.AWSconnstring()).GetAllReviews() .FindAll(review => review.User.UserName.ToLower().Equals(username.ToLower())); if (list.Count > 0) { return(Ok(list)); } else { return(StatusCode(404, "There are no results for this user")); } }