Exemplo n.º 1
0
        public void CreateTest()
        {
            // Arrange
            db = new touch_for_foodEntities();
            RestaurantUserController target = new RestaurantUserController();
            int numExpectedAssociations = db.restaurant_user.ToList<restaurant_user>().Count() + 1;

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

            // Assertions
            db = new touch_for_foodEntities();
            var actualResultURI = actualResult.RouteValues["action"];
            int actualRestoUsers = db.restaurant_user.ToList<restaurant_user>().Count();
            Assert.AreEqual(numExpectedAssociations, actualRestoUsers);
            Assert.AreEqual("Index", actualResultURI);
        }
Exemplo n.º 2
0
        public void CreateViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            RestaurantUserController target = new RestaurantUserController();
            SelectList expectedRestoList = new SelectList(db.restaurants, "id", "name");
            SelectList expectedUsersList = new SelectList(db.users.Where(u => u.user_role == (int)SiteRoles.Restaurant
                || u.user_role == (int)SiteRoles.Admin), "id", "username");
            ViewResult actual;

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

            //Assert
            SelectList actualRestoList = actual.ViewBag.restaurant_id;
            Assert.AreEqual(expectedRestoList.GetType(), actualRestoList.GetType());
            Assert.AreEqual(expectedRestoList.Count(), actualRestoList.Count());

            SelectList actualUserList = actual.ViewBag.user_id;
            Assert.AreEqual(expectedUsersList.GetType(), actualUserList.GetType());
            Assert.AreEqual(expectedUsersList.Count(), actualUserList.Count());
        }