Example #1
0
        public ActionResult Edit(string editDescription, string EditId)
        {
            int id = int.Parse(EditId);

            FavRestaurant.FindById(id).EditDescription(editDescription);
            return(RedirectToAction("Index"));
        }
Example #2
0
        public ActionResult Delete(string deleteId)
        {
            int id = int.Parse(deleteId);

            FavRestaurant.FindById(id).Delete();
            return(RedirectToAction("Index"));
        }
Example #3
0
        public void Equals_ReturnsTrueIfNameAndDescriptionsAreTheSame_FavRestaurant()
        {
            // Arrange, Act
            FavRestaurant firstFavRestaurant  = new FavRestaurant("testName", "testCuisine", "testDescription", "testLocation", 1);
            FavRestaurant secondFavRestaurant = new FavRestaurant("testName", "testCuisine", "testDescription", "testLocation", 1);

            // Assert
            Assert.AreEqual(firstFavRestaurant, secondFavRestaurant);
        }
Example #4
0
        public void Find_FindIdInDatabase_FavRestaurant()
        {
            //Arrange
            FavRestaurant testFavRestaurant = new FavRestaurant("testName", "testCuisine", "testDescription", "testLocation");

            testFavRestaurant.Save();

            //Act
            FavRestaurant resultRestaurant = FavRestaurant.FindById(testFavRestaurant.GetId());

            //Assert
            Assert.AreEqual(testFavRestaurant, resultRestaurant);
        }
Example #5
0
        public ActionResult Search(string searchFx, string searchTerm)
        {
            List <FavRestaurant> foundRestaurants = new List <FavRestaurant> {
            };

            if (searchFx.Equals("byName"))
            {
                foundRestaurants = FavRestaurant.FindByName(searchTerm);
            }
            else
            {
                foundRestaurants = FavRestaurant.FindByCuisine(searchTerm);
            }
            return(View("Index", foundRestaurants));
        }
Example #6
0
        public void Save_AssignsIdToObject_Id()
        {
            //Arrange
            FavRestaurant testFavRestaurant = new FavRestaurant("testName", "testCuisine", "testDescription", "testLocation");

            //Act
            testFavRestaurant.Save();
            FavRestaurant savedFavRestaurant = FavRestaurant.GetAll()[0];

            int result = savedFavRestaurant.GetId();
            int testId = testFavRestaurant.GetId();

            //Assert
            Assert.AreEqual(testId, result);
        }
Example #7
0
        public void Save_SavesToDatabase_FavRestaurant()
        {
            //Arrange
            FavRestaurant testFavRestaurant = new FavRestaurant("testName", "testCuisine", "testDescription", "testLocation");

            //Act
            testFavRestaurant.Save();
            List <FavRestaurant> result   = FavRestaurant.GetAll();
            List <FavRestaurant> testList = new List <FavRestaurant> {
                testFavRestaurant
            };

            Console.WriteLine(result[0].GetId());
            //Assert
            CollectionAssert.AreEqual(testList, result);
        }
Example #8
0
        public void Delete_DeleteFavRestaurantEntry()
        {
            // Arrange
            List <FavRestaurant> testList   = new List <FavRestaurant> {
            };
            FavRestaurant testFavRestaurant = new FavRestaurant("testName", "testCuisine", "testDescription", "testLocation");

            testFavRestaurant.Save();

            // Act
            FavRestaurant.FindById(testFavRestaurant.GetId()).Delete();
            List <FavRestaurant> resultList = FavRestaurant.GetAll();

            // Assert
            CollectionAssert.AreEqual(testList, resultList);
        }
Example #9
0
        public void Find_FindNameInDatabase_FavRestaurant()
        {
            //Arrange
            List <FavRestaurant> testList   = new List <FavRestaurant> {
            };
            FavRestaurant testFavRestaurant = new FavRestaurant("testName", "testCuisine", "testDescription", "testLocation");

            testFavRestaurant.Save();
            testList.Add(testFavRestaurant);

            //Act
            List <FavRestaurant> resultList = FavRestaurant.FindByName(testFavRestaurant.GetName());

            //Assert
            CollectionAssert.AreEqual(testList, resultList);
        }
Example #10
0
        public void Edit_UpdatesDescriptionInDatabase_String()
        {
            //Arrange
            string        firstDescription  = "Food";
            FavRestaurant testFavRestaurant = new FavRestaurant("testName", "testCuisine", firstDescription, "testLocation");

            testFavRestaurant.Save();
            string secondDescription = "Americana and Asian Fusion";

            //Act
            testFavRestaurant.EditDescription(secondDescription);

            string result = FavRestaurant.FindById(testFavRestaurant.GetId()).GetDescription();

            //Assert
            Assert.AreEqual(secondDescription, result);
        }
Example #11
0
        public ActionResult Create(string restName, string restType, string restLocation, string restDescription)
        {
            string restaurantDescription = "";
            string restaurantLocation    = "";

            if (!string.IsNullOrWhiteSpace(Request.Form["restDescription"]))
            {
                restaurantDescription = restDescription;
            }
            if (!string.IsNullOrWhiteSpace(Request.Form["restLocation"]))
            {
                restaurantLocation = restLocation;
            }
            FavRestaurant createRestaurant = new FavRestaurant(restName, restType, restaurantLocation, restaurantDescription);

            createRestaurant.Save();
            return(RedirectToAction("Index"));
        }
Example #12
0
        public void GetTest_ReturnDataField()
        {
            // arrange
            int           id             = 1;
            string        name           = "Pig House";
            string        description    = "Best of Americana and Asian.";
            string        location       = "Seattle";
            string        cuisine        = "Asian Fusion";
            FavRestaurant testRestaurant = new FavRestaurant(name, cuisine, description, location, id);

            // act
            int    resultId          = testRestaurant.GetId();
            string resultName        = testRestaurant.GetName();
            string resultDescription = testRestaurant.GetDescription();
            string resultLocation    = testRestaurant.GetLocation();
            string resultCuisine     = testRestaurant.GetCuisine();

            // assert
            Assert.AreEqual(id, resultId);
            Assert.AreEqual(name, resultName);
            Assert.AreEqual(description, resultDescription);
            Assert.AreEqual(location, resultLocation);
            Assert.AreEqual(cuisine, resultCuisine);
        }
Example #13
0
        public ActionResult FindByCuisine(string cuisine)
        {
            List <FavRestaurant> matchCuisines = FavRestaurant.FindByCuisine(cuisine);

            return(View("Index", matchCuisines));
        }
Example #14
0
 public ActionResult EditForm(int id)
 {
     return(View(FavRestaurant.FindById(id)));
 }
Example #15
0
        public ActionResult Index()
        {
            List <FavRestaurant> allRestaurants = FavRestaurant.GetAll();

            return(View(allRestaurants));
        }
Example #16
0
 public void Dispose()
 {
     FavRestaurant.DeleteAll();
 }