public void TestReviewsIndex() { //Arrange FakeRestaurantRepository fakeRestaurantRepository = new FakeRestaurantRepository(); FakeReviewRepository fakeReviewRepository = new FakeReviewRepository(); ReviewsController controller = new ReviewsController(fakeRestaurantRepository, fakeReviewRepository); //Act var result = controller.Index("byRevName") as ViewResult; //Assert Assert.IsNotNull(result); }
public void TestRestaurantsCreate() { //Arrange FakeRestaurantRepository fakeRestaurantRepository = new FakeRestaurantRepository(); FakeReviewRepository fakeReviewRepository = new FakeReviewRepository(); RestaurantsController controller = new RestaurantsController(fakeRestaurantRepository, fakeReviewRepository); //Act var result = controller.Create() as ViewResult; //Assert Assert.IsNotNull(result); }
public void TestReviewsDetails() { //Arrange FakeRestaurantRepository fakeRestaurantRepository = new FakeRestaurantRepository(); FakeReviewRepository fakeReviewRepository = new FakeReviewRepository(); ReviewsController controller = new ReviewsController(fakeRestaurantRepository, fakeReviewRepository); //Act var result = controller.Details(1) as ViewResult; var data = result.Model as Review; //Assert Assert.IsNotNull(result); Assert.AreEqual("A", data.ReviewerName); }
public void TestRestaurantsDelete() { //Arrange FakeRestaurantRepository fakeRestaurantRepository = new FakeRestaurantRepository(); FakeReviewRepository fakeReviewRepository = new FakeReviewRepository(); RestaurantsController controller = new RestaurantsController(fakeRestaurantRepository, fakeReviewRepository); //Act var result = controller.Delete(1) as ViewResult; var data = result.Model as Restaurant; //Assert Assert.IsNotNull(result); Assert.AreEqual(data.Name, "McD"); }
public void TestReviewsCreate() { //Arrange FakeRestaurantRepository fakeRestaurantRepository = new FakeRestaurantRepository(); FakeReviewRepository fakeReviewRepository = new FakeReviewRepository(); ReviewsController controller = new ReviewsController(fakeRestaurantRepository, fakeReviewRepository); ReviewsCreateVM vm = new ReviewsCreateVM(fakeRestaurantRepository); string e2RestName = "McD"; //Act var result = controller.Create(vm) as ActionResult; var result2 = controller.Create(1) as ViewResult; var data2 = result2.Model as ReviewsCreateVM; //Assert Assert.IsNotNull(result); Assert.IsNotNull(result2); Assert.AreEqual(e2RestName, data2.Restaurants.First(x => x.ID == data2.Review.RestaurantID).Name); }
public void TestRestaurantsDetails() { //Arrange FakeRestaurantRepository fakeRestaurantRepository = new FakeRestaurantRepository(); FakeReviewRepository fakeReviewRepository = new FakeReviewRepository(); RestaurantsController controller = new RestaurantsController(fakeRestaurantRepository, fakeReviewRepository); string e1 = "Meat"; string e2 = "Meat"; //Act var result1 = controller.Details(1) as ViewResult; var data1 = result1.Model as RestaurantDetailsVM; var result2 = controller.Details(2) as ViewResult; var data2 = result2.Model as RestaurantDetailsVM; //Assert Assert.IsNotNull(result1); Assert.AreEqual(e1, data1.Restaurant.Cuisine); Assert.IsNotNull(result2); Assert.AreEqual(e2, data2.Restaurant.Cuisine); }
public void TestRestaurantsIndex() { //Arrange FakeRestaurantRepository fakeRestaurantRepository = new FakeRestaurantRepository(); FakeReviewRepository fakeReviewRepository = new FakeReviewRepository(); RestaurantsController controller = new RestaurantsController(fakeRestaurantRepository, fakeReviewRepository); string e1 = "Acme"; string e2 = "Citrus"; //Act var result1 = controller.Index("byName") as ViewResult; var data1 = result1.Model as List <Restaurant>; var result2 = controller.Index("byCuisine") as ViewResult; var data2 = result2.Model as List <Restaurant>; //Assert Assert.IsNotNull(result1); Assert.AreEqual(e1, data1[0].Name); Assert.IsNotNull(result2); Assert.AreEqual(e2, data2[0].Name); }