public void EditTestInvalidStateModel()
        {
            // Arrange
            db = new touch_for_foodEntities();
            FriendshipController target = new FriendshipController();
            long expected = friendship1.id;
            SelectList expectedUser1List = new SelectList(db.users, "id", "username", user1);
            SelectList expectedUser2List = new SelectList(db.users, "id", "username", user2);
            friendship1.second_user = user3.id;
            target.ModelState.AddModelError("error", "ModelState is invalid");

            // Act
            ViewResult actual = (ViewResult)target.Edit(friendship1);

            // Assert
            SelectList actualUser1List = actual.ViewBag.first_user;
            SelectList actualUser2List = actual.ViewBag.second_user;
            string errorMsg = actual.ViewBag.Error;
            Assert.AreEqual(((friendship)actual.Model).id, expected);
            Assert.AreEqual(expectedUser1List.GetType(), actualUser1List.GetType());
            Assert.AreEqual(expectedUser2List.GetType(), actualUser2List.GetType());
            Assert.AreEqual(expectedUser1List.Count(), actualUser1List.Count());
            Assert.AreEqual(expectedUser2List.Count(), actualUser2List.Count());
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
        public void EditViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            FriendshipController target = new FriendshipController();
            long expected = friendship1.id;
            SelectList expectedUser1List = new SelectList(db.users, "id", "username", user1);
            SelectList expectedUser2List = new SelectList(db.users, "id", "username", user2);

            //Act
            ViewResult actual = (ViewResult)target.Edit(friendship1.id);

            //Assert
            SelectList actualUser1List = actual.ViewBag.first_user;
            SelectList actualUser2List = actual.ViewBag.second_user;
            Assert.AreEqual(((friendship)actual.Model).id, expected);
            Assert.AreEqual(expectedUser1List.GetType(), actualUser1List.GetType());
            Assert.AreEqual(expectedUser2List.GetType(), actualUser2List.GetType());
            Assert.AreEqual(expectedUser1List.Count(), actualUser1List.Count());
            Assert.AreEqual(expectedUser2List.Count(), actualUser2List.Count());
        }
        public void EditTest()
        {
            //Arrange
            FriendshipController target = new FriendshipController();
            friendship1.second_user = user3.id;

            //Act
            var actualResult = target.Edit(friendship1) as RedirectToRouteResult;

            //Assert
            db = new touch_for_foodEntities();
            var actualResultURI = actualResult.RouteValues["action"];
            Assert.AreEqual("Index", actualResultURI);
            Assert.AreEqual(db.friendships.Find(friendship1.id).second_user, user3.id);
        }