public void CreateViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            FriendshipController target = new FriendshipController();
            SelectList expectedUserList = new SelectList(db.users, "id", "username");

            //Act
            ViewResult actual = (ViewResult)target.Create();

            //Assert
            SelectList actualUser1List = actual.ViewBag.first_user;
            SelectList actualUser2List = actual.ViewBag.second_user;
            Assert.AreEqual(expectedUserList.GetType(), actualUser1List.GetType());
            Assert.AreEqual(expectedUserList.GetType(), actualUser2List.GetType());
            Assert.AreEqual(expectedUserList.Count(), actualUser1List.Count());
            Assert.AreEqual(expectedUserList.Count(), actualUser2List.Count());
        }
        public void CreateTest()
        {
            // Arrange
            db = new touch_for_foodEntities();
            FriendshipController target = new FriendshipController();
            int expectedFriendships = db.friendships.ToList<friendship>().Count()+1;

            // Act
            var actualResult = target.Create(friendship2) as RedirectToRouteResult;

            // Assertions
            db = new touch_for_foodEntities();
            var actualResultURI = actualResult.RouteValues["action"];
            int actualFriendships = db.friendships.ToList<friendship>().Count();
            Assert.AreEqual(expectedFriendships, actualFriendships);
            Assert.AreEqual("Index", actualResultURI);
        }
        public void CreateTestInvalidStateModel()
        {
            // Arrange
            db = new touch_for_foodEntities();
            FriendshipController target = new FriendshipController();
            long expected = friendship1.id;
            SelectList expectedUserList = new SelectList(db.users, "id", "username");
            target.ModelState.AddModelError("error", "ModelState is invalid");

            // Act
            ViewResult actual = (ViewResult)target.Create(friendship2);

            // Assert
            SelectList actualUser1List = actual.ViewBag.first_user;
            SelectList actualUser2List = actual.ViewBag.second_user;
            string errorMsg = actual.ViewBag.Error;
            Assert.AreEqual("Create", actual.ViewName);
            Assert.AreEqual(expectedUserList.GetType(), actualUser1List.GetType());
            Assert.AreEqual(expectedUserList.GetType(), actualUser2List.GetType());
            Assert.AreEqual(expectedUserList.Count(), actualUser1List.Count());
            Assert.AreEqual(expectedUserList.Count(), actualUser2List.Count());
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }