Пример #1
0
        public static void MyClassInitialize(TestContext testContext)
        {
            //Add test data (order specific)
            testDatabase = new TestDatabaseHelper();
            restaurant1 = testDatabase.AddRestaurant();
            table1 = testDatabase.AddTable(restaurant1);
            user1 = testDatabase.AddUser("*****@*****.**", table1, (int)SiteRoles.Admin);

            //Session
            db = new touch_for_foodEntities();
            target = new HomeController();
            Session session = new Session(db, target);
            session.simulateLogin(user1.username, user1.password);
        }
Пример #2
0
        public void CreateUserDBEntityValidationExceptionTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            UserController target = new UserController();
            user2.email = null;
            user2.username = null;
            int expectedUsers = db.users.ToList<user>().Count();
            Session session = new Session(db, target);

            var actual = target.Create(user2) as ViewResult;

            // Assert
            db = new touch_for_foodEntities();
            int actualUsers = db.users.ToList<user>().Count();
            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
            Assert.AreEqual(expectedUsers, actualUsers);
            Assert.AreEqual("Create", actual.ViewName); //Directed to correct location
        }
Пример #3
0
        public static void MyClassInitialize(TestContext testContext)
        {
            //Add test data (order specific)
            testDatabase = new TestDatabaseHelper();
            restaurant1 = testDatabase.AddRestaurant();
            table1 = testDatabase.AddTable(restaurant1);
            user1 = testDatabase.AddUser("*****@*****.**", table1, (int)SiteRoles.Customer);
            order1 = testDatabase.AddOrder(table1);
            item1 = testDatabase.AddItem();
            category1 = testDatabase.AddCategory();
            menu1 = testDatabase.AddMenu(restaurant1);
            menuCategory1 = testDatabase.AddMenuCategory(category1, menu1);
            menuItem1 = testDatabase.AddMenuItem(item1, menuCategory1);
            orderItem1 = testDatabase.AddOrderItem(order1, menuItem1);

            //Session
            db = new touch_for_foodEntities();
            ReviewController target = new ReviewController();
            Session session = new Session(db, target);
            session.simulateLogin(user1.username, user1.password);
        }
Пример #4
0
        public void MyTestInitialize()
        {
            //Add test data (order specific)
            order1 = testDatabase.AddOrder(table1);

            //Session
            db = new touch_for_foodEntities();
            target = new OrderController();
            Session session = new Session(db, target);
            session.simulateLogin(user1.username, user1.password);
        }
Пример #5
0
        public void EditViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            UserController target = new UserController();
            Session session = new Session(db, target);
            session.simulateLogin(user1.username, user1.password);
            int expected = user1.id;

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

            //Assert
            Assert.AreEqual(((user)actual.Model).id, expected);
        }
Пример #6
0
        public void EditViewInvalidUserTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            UserController target = new UserController();
            Session session = new Session(db, target);
            session.simulateLogin(user1.username, user1.password);

            //Act
            var actualResult = target.Edit(user3.id) as RedirectToRouteResult;
            var actualResultURI = actualResult.RouteValues["controller"] + "/" + actualResult.RouteValues["action"];

            //Assertions
            Assert.AreEqual("Home/Index", actualResultURI);
        }
Пример #7
0
        public void MyTestInitialize()
        {
            //Add test data (order specific)
            restaurant1 = testDatabase.AddRestaurant();
            restaurant2 = new restaurant();
            table1 = testDatabase.AddTable(restaurant1);
            user1 = testDatabase.AddUser("*****@*****.**", table1, (int)SiteRoles.Admin);
            restaurantUser1 = testDatabase.AddRestaurantUser(user1, restaurant1);
            menu1 = testDatabase.AddMenu(restaurant1);
            order1 = testDatabase.AddOrder(table1);
            review1 = testDatabase.AddReview(restaurant1, order1, user1);

            //Session
            db = new touch_for_foodEntities();
            target = new RestaurantController();
            Session session = new Session(db, target);
            session.simulateLogin(user1.username, user1.password);
        }
Пример #8
0
        public void MyTestInitialize()
        {
            //Add test data (order specific)
            item1 = testDatabase.AddItem(category1);
            menu1 = testDatabase.AddMenu(restaurant1);
            menuCategory1 = testDatabase.AddMenuCategory(category1, menu1);

            //Session
            db = new touch_for_foodEntities();
            target = new ItemController(db);
            Session session = new Session(db, target);
            session.simulateLogin(user1.username, user1.password);
        }
Пример #9
0
        public void MyTestInitialize()
        {
            //Add test data (order specific)
            category1 = testDatabase.AddCategory();
            category2 = testDatabase.AddCategory();
            category3 = new category();
            category3.name = "CategoryUnitTest";
            category3.version = 1;
            menuCategory1 = testDatabase.AddMenuCategory(category2, menu1);

            //Session
            target = new CategoryController();
            Session session = new Session(db, target);
        }
Пример #10
0
        public void MyTestInitialize()
        {
            //Add test data (order specific)
            restaurant1 = testDatabase.AddRestaurant();
            table1 = testDatabase.AddTable(restaurant1);
            table2 = new table();
            user1 = testDatabase.AddUser("*****@*****.**", table1, (int)SiteRoles.Restaurant);
            order1 = testDatabase.AddOrder(table1);
            request1 = testDatabase.AddServiceRequest(table1);
            restaurantUser1 = testDatabase.AddRestaurantUser(user1, restaurant1);

            //Session
            db = new touch_for_foodEntities();
            target = new TableController();
            Session session = new Session(db, target);
            session.simulateLogin(user1.username, user1.password);
        }
Пример #11
0
        public void MyTestInitialize()
        {
            request1 = testDatabase.AddServiceRequest(table1);

            //Session
            db = new touch_for_foodEntities();
            target = new ServiceRequestController();
            Session session = new Session(db, target);
            session.simulateLogin(user1.username, user1.password);
        }