// GET: Restaurant/Details/5 public ActionResult Details(PLC.Restaurant rest) { if (isValid(rest)) { if (func == null) { func = new PLC.Functionality(); } // Grab all of the selected Restaurant's reviews var reviews = func.GetReviews(rest.RestaurantID); // Add the RestaurantID to each of the review objects for future reference foreach (var review in reviews) { review.RestaurantID = rest.RestaurantID; } if (reviews.Count == 0) { reviews.Add(new PLC.Review() { RestaurantID = rest.RestaurantID }); } return(View(reviews)); } else { return(RedirectToAction("Index")); } }
public void TestReviewDetails() { ReviewController rc = new ReviewController(); PLC.Functionality func = new PLC.Functionality(); var reviews = func.GetReviews(1); // Grab Carl's Jr. reviews string expected = "zschiesterl11"; // Reviewer that gave Carl's Jr. a rating of 4 var action = rc.Edit(reviews[reviews.Count - 2]) as ViewResult; var actual = ((PLC.Review)action.Model).Author; // The actual reviewer that was passed to the view Assert.AreEqual(expected, actual); }