Пример #1
0
        public void EditBillTestLockError()
        {
            // Arrange
            db = new touch_for_foodEntities();
            BillController target = new BillController();
            SelectList expectedOrderList = new SelectList(db.orders, "id", "id", bill1.order_id);
            ViewResult actual;
            bill1.version += 5;

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

            // Assert
            SelectList actualOrderList = actual.ViewBag.order_id;
            Assert.AreEqual(expectedOrderList.GetType(), actualOrderList.GetType());
            Assert.AreEqual(expectedOrderList.Count(), actualOrderList.Count());

            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
Пример #2
0
        public void EditViewTest()
        {
            // Arrange
            db = new touch_for_foodEntities();
            int expected = request1.id;
            SelectList expectedTableList = new SelectList(db.tables, "id", "name", request1.table_id);
            ViewResult actual;

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

            // Assert
            Assert.AreEqual(expected, ((service_request)actual.ViewData.Model).id);

            SelectList actualTableList = actual.ViewBag.table_id;
            Assert.AreEqual(expectedTableList.GetType(), actualTableList.GetType());
            Assert.AreEqual(expectedTableList.Count(), actualTableList.Count());
        }
Пример #3
0
        public void CreateViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            BillController target = new BillController();
            SelectList orderList = new SelectList(db.orders, "id", "id");

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

            //Assert
            Assert.AreEqual(orderList.GetType(), actual.ViewBag.order_id.GetType());
        }
Пример #4
0
        public void CreateTestInvalidStateModel()
        {
            // Arrange
            db = new touch_for_foodEntities();
            Menu_ItemController target = new Menu_ItemController();
            target.ModelState.AddModelError("error", "ModelState is invalid");
            SelectList expectedItemList = new SelectList(db.items, "id", "name", menuItem2.item_id);
            SelectList expectedCategoryList = new SelectList(db.menu_category, "id", "id", menuItem2.menu_category_id);
            ViewResult actual;

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

            // Assert
            SelectList actualItemList = actual.ViewBag.item_id;
            Assert.AreEqual(expectedItemList.GetType(), actualItemList.GetType());
            Assert.AreEqual(expectedItemList.Count(), actualItemList.Count());

            SelectList actualCategoryList = actual.ViewBag.menu_category_id;
            Assert.AreEqual(expectedCategoryList.GetType(), actualCategoryList.GetType());
            Assert.AreEqual(expectedCategoryList.Count(), actualCategoryList.Count());

            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
Пример #5
0
        public void EditTestLockFailure()
        {
            // Arrange
            db = new touch_for_foodEntities();
            Menu_ItemController target = new Menu_ItemController();
            int expected = menuItem1.id;
            SelectList expectedItemList = new SelectList(db.items, "id", "name", menuItem1.item_id);
            SelectList expectedCategoryList = new SelectList(db.menu_category, "id", "id", menuItem1.menu_category_id);
            ViewResult actual;
            menuItem1.version += 5;

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

            // Assert
            Assert.AreEqual(expected, ((menu_item)actual.ViewData.Model).id);

            SelectList actualItemList = actual.ViewBag.item_id;
            Assert.AreEqual(expectedItemList.GetType(), actualItemList.GetType());
            Assert.AreEqual(expectedItemList.Count(), actualItemList.Count());

            SelectList actualCategoryList = actual.ViewBag.menu_category_id;
            Assert.AreEqual(expectedCategoryList.GetType(), actualCategoryList.GetType());
            Assert.AreEqual(expectedCategoryList.Count(), actualCategoryList.Count());

            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
Пример #6
0
        public void EditTestLockError()
        {
            // Arrange
            db = new touch_for_foodEntities();
            Order_ItemController target = new Order_ItemController();
            int expected = orderItem1.id;
            orderItem1.version += 5;
            SelectList expectedMenuList = new SelectList(db.menu_item, "id", "id", orderItem1.menu_item_id);
            SelectList expectedOrderList = new SelectList(db.orders, "id", "id", orderItem1.order_id);
            ViewResult actual;

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

            // Assert
            Assert.AreEqual(expected, ((order_item)actual.ViewData.Model).id);

            SelectList actualMenuList = actual.ViewBag.menu_item_id;
            Assert.AreEqual(expectedMenuList.GetType(), actualMenuList.GetType());
            Assert.AreEqual(expectedMenuList.Count(), actualMenuList.Count());

            SelectList actualOrderList = actual.ViewBag.order_id;
            Assert.AreEqual(expectedOrderList.GetType(), actualOrderList.GetType());
            Assert.AreEqual(expectedOrderList.Count(), actualOrderList.Count());

            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
Пример #7
0
        public void EditVersionErrorTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            Menu_CategoryController target = new Menu_CategoryController(db);
            SelectList mcList = new SelectList(db.categories, "id", "name", menuCategory1.category_id);
            SelectList menuList = new SelectList(db.menus, "id", "name", menuCategory1.menu_id);
            Assert.IsFalse(db.menu_category.Find(menuCategory1.id).is_active);
            menuCategory1.is_active = true;
            menuCategory1.version -= 1;

            //Act
            var actual = (ViewResult)target.Edit(menuCategory1);

            //Assert
            db = new touch_for_foodEntities();
            Assert.IsFalse(db.menu_category.Find(menuCategory1.id).is_active);
            Assert.AreEqual(mcList.GetType(), actual.ViewBag.category_id.GetType());
            Assert.AreEqual(menuList.GetType(), actual.ViewBag.menu_id.GetType());
            Assert.IsNotNull(actual.ViewBag.Error);
        }
Пример #8
0
        public void EditTableTestInvalidStateModel()
        {
            // Arrange
            db = new touch_for_foodEntities();
            target.ModelState.AddModelError("error", "ModelState is invalid");
            int expected = table1.id;
            SelectList expectedRestos = new SelectList(db.restaurants, "id", "name", table1.restaurant_id);
            ViewResult actual;

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

            // Assert
            Assert.AreEqual(expected, ((table)actual.ViewData.Model).id);

            SelectList actualRestos = actual.ViewBag.restaurant_id;
            Assert.AreEqual(expectedRestos.GetType(), actualRestos.GetType());
            Assert.AreEqual(expectedRestos.Count(), actualRestos.Count());

            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
Пример #9
0
        public void EditTest()
        {
            //Setup
            int expected = table1.id;
            SelectList expectedRestoList = new SelectList(db.restaurants, "id", "name", table1.restaurant_id);

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

            //Assert
            Assert.AreEqual(((table)actual.Model).id, expected);
            Assert.AreEqual(expectedRestoList.GetType(), actual.ViewBag.restaurant_id.GetType());
            SelectList actualRestoList = actual.ViewBag.restaurant_id;
            Assert.AreEqual(expectedRestoList.Count(), actualRestoList.Count());
        }
Пример #10
0
        public void EditVersionErrorTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            SelectList expectedRestoList = new SelectList(db.restaurants, "id", "name", menu1.id);
            string changeString = "UnitTesting";
            menu1.version += 5;
            menu1.name = changeString;

            //Act
            var actual = target.Edit(menu1) as ViewResult;

            //Assert
            db = new touch_for_foodEntities();
            Assert.IsFalse(db.menus.Find(menu1.id).name.Equals(changeString));
            Assert.AreEqual(((menu)actual.Model).id, menu1.id);
            Assert.AreEqual(expectedRestoList.GetType(), actual.ViewBag.resto_id.GetType());
            SelectList actualRestoList = actual.ViewBag.resto_id;
            Assert.AreEqual(expectedRestoList.Count(), actualRestoList.Count());
        }
Пример #11
0
        public void EditViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            SelectList expectedRestoList = new SelectList(db.restaurants, "id", "name", menu1.id);

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

            //Assert
            Assert.AreEqual(((menu)actual.Model).id, menu1.id);
            Assert.AreEqual(expectedRestoList.GetType(), actual.ViewBag.resto_id.GetType());
            SelectList actualRestoList = actual.ViewBag.resto_id;
            Assert.AreEqual(expectedRestoList.Count(), actualRestoList.Count());
        }
Пример #12
0
        public void CreateViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            SelectList expectedRestoList = new SelectList(db.restaurants, "id", "name", db.restaurants.First().id);

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

            //Assert
            Assert.AreEqual(expectedRestoList.GetType(), actual.ViewBag.resto_id.GetType());
            SelectList actualRestoList = actual.ViewBag.resto_id;
            Assert.AreEqual(expectedRestoList.Count(), actualRestoList.Count());
        }
Пример #13
0
        public void CreateTestInvalidStateModel()
        {
            // Arrange
            db = new touch_for_foodEntities();
            target.ModelState.AddModelError("error", "ModelState is invalid");
            SelectList expectedRestoList = new SelectList(db.restaurants, "id", "name", menu1.resto_id);
            ViewResult actual;

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

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

            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
Пример #14
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());
        }
Пример #15
0
        public void CreateTestInvalidStateModel()
        {
            // Arrange
            db = new touch_for_foodEntities();
            Order_ItemController target = new Order_ItemController();
            target.ModelState.AddModelError("error", "ModelState is invalid");
            SelectList expectedMenuList = new SelectList(db.menu_item, "id", "id", orderItem3.menu_item_id);
            SelectList expectedOrderList = new SelectList(db.orders, "id", "id", orderItem3.order_id);
            ViewResult actual;

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

            // Assert
            SelectList actualMenuList = actual.ViewBag.menu_item_id;
            Assert.AreEqual(expectedMenuList.GetType(), actualMenuList.GetType());
            Assert.AreEqual(expectedMenuList.Count(), actualMenuList.Count());

            SelectList actualOrderList = actual.ViewBag.order_id;
            Assert.AreEqual(expectedOrderList.GetType(), actualOrderList.GetType());
            Assert.AreEqual(expectedOrderList.Count(), actualOrderList.Count());

            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
Пример #16
0
        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());
        }
Пример #17
0
        public void CreateViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            Order_ItemController target = new Order_ItemController();
            SelectList expectedMenuList = new SelectList(db.menu_item, "id", "id");
            SelectList expectedOrderList = new SelectList(db.orders, "id", "id");
            ViewResult actual;

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

            //Assert
            SelectList actualMenuList = actual.ViewBag.menu_item_id;
            Assert.AreEqual(expectedMenuList.GetType(), actualMenuList.GetType());
            Assert.AreEqual(expectedMenuList.Count(), actualMenuList.Count());

            SelectList actualOrderList = actual.ViewBag.order_id;
            Assert.AreEqual(expectedOrderList.GetType(), actualOrderList.GetType());
            Assert.AreEqual(expectedOrderList.Count(), actualOrderList.Count());
        }
Пример #18
0
        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
        }
Пример #19
0
        public void EditViewTest()
        {
            // Arrange
            db = new touch_for_foodEntities();
            Order_ItemController target = new Order_ItemController();
            int expected = orderItem1.id;
            SelectList expectedMenuList = new SelectList(db.menu_item, "id", "id", orderItem1.menu_item_id);
            SelectList expectedOrderList = new SelectList(db.orders, "id", "id", orderItem1.order_id);
            ViewResult actual;

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

            // Assert
            Assert.AreEqual(expected, ((order_item)actual.ViewData.Model).id);

            SelectList actualMenuList = actual.ViewBag.menu_item_id;
            Assert.AreEqual(expectedMenuList.GetType(), actualMenuList.GetType());
            Assert.AreEqual(expectedMenuList.Count(), actualMenuList.Count());

            SelectList actualOrderList = actual.ViewBag.order_id;
            Assert.AreEqual(expectedOrderList.GetType(), actualOrderList.GetType());
            Assert.AreEqual(expectedOrderList.Count(), actualOrderList.Count());
        }
Пример #20
0
        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());
        }
Пример #21
0
        public void EditViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            Menu_CategoryController target = new Menu_CategoryController(db);
            SelectList mcList = new SelectList(db.categories, "id", "name", menuCategory1.category_id);
            SelectList menuList = new SelectList(db.menus, "id", "name", menuCategory1.menu_id);

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

            //Assert
            Assert.AreEqual(mcList.GetType(), actual.ViewBag.category_id.GetType());
            Assert.AreEqual(menuList.GetType(), actual.ViewBag.menu_id.GetType());
        }
Пример #22
0
        public void EditViewTest()
        {
            // Arrange
            db = new touch_for_foodEntities();
            SideController target = new SideController();
            int expected = side1.id;
            SelectList expectedSideList = new SelectList(db.menu_category, "id", "id", side1.menu_category_id);

            ViewResult actual;

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

            // Assert
            Assert.AreEqual(expected, ((side)actual.ViewData.Model).id);

            SelectList actualSideList = actual.ViewBag.menu_category_id;
            Assert.AreEqual(expectedSideList.GetType(), actualSideList.GetType());
            Assert.AreEqual(expectedSideList.Count(), actualSideList.Count());
        }
Пример #23
0
        public void CreateViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            Menu_ItemController target = new Menu_ItemController();
            SelectList expectedItemList = new SelectList(db.items, "id", "name");
            SelectList expectedCategoryList = new SelectList(db.menu_category, "id", "id");
            ViewResult actual;

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

            //Assert
            SelectList actualItemList = actual.ViewBag.item_id;
            Assert.AreEqual(expectedItemList.GetType(), actualItemList.GetType());
            Assert.AreEqual(expectedItemList.Count(), actualItemList.Count());

            SelectList actualCategoryList = actual.ViewBag.menu_category_id;
            Assert.AreEqual(expectedCategoryList.GetType(), actualCategoryList.GetType());
            Assert.AreEqual(expectedCategoryList.Count(), actualCategoryList.Count());
        }
Пример #24
0
        public void CreateViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            SelectList expectedCategoryList = new SelectList(db.categories, "id", "name");
            ViewResult actual;

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

            //Assert
            SelectList actualCategoryList = actual.ViewBag.category_id;
            Assert.AreEqual(expectedCategoryList.GetType(), actualCategoryList.GetType());
            Assert.AreEqual(expectedCategoryList.Count(), actualCategoryList.Count());
        }
Пример #25
0
        public void EditViewTest()
        {
            // Arrange
            db = new touch_for_foodEntities();
            Menu_ItemController target = new Menu_ItemController();
            int expected = menuItem1.id;
            SelectList expectedItemList = new SelectList(db.items, "id", "name", menuItem1.item_id);
            SelectList expectedCategoryList = new SelectList(db.menu_category, "id", "id", menuItem1.menu_category_id);
            ViewResult actual;

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

            // Assert
            Assert.AreEqual(expected, ((menu_item)actual.ViewData.Model).id);

            SelectList actualItemList = actual.ViewBag.item_id;
            Assert.AreEqual(expectedItemList.GetType(), actualItemList.GetType());
            Assert.AreEqual(expectedItemList.Count(), actualItemList.Count());

            SelectList actualCategoryList = actual.ViewBag.menu_category_id;
            Assert.AreEqual(expectedCategoryList.GetType(), actualCategoryList.GetType());
            Assert.AreEqual(expectedCategoryList.Count(), actualCategoryList.Count());
        }
Пример #26
0
        public void CreateViewAdministratorServiceRequestTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            SelectList requestList = new SelectList(db.tables, "id", "name");

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

            //Assert
            Assert.AreEqual(requestList.GetType(), actual.ViewBag.table_id.GetType());
            SelectList newRequestList = actual.ViewBag.table_id;
            Assert.AreEqual(requestList.Count(), newRequestList.Count());
        }