コード例 #1
0
        public void non_admin_customer_customer_details_httppost()
        {
            //Arrange
            CustomerController controller = new CustomerController(new CustomerBLL(new CustomerDALStub()));

            //Act
            var result = (RedirectToRouteResult)controller.CustomerDetails(null);

            //Assert

            Assert.AreEqual("LogIn", result.RouteValues["Action"]);
            Assert.AreEqual("Main", result.RouteValues["Controller"]);
        }
コード例 #2
0
        public void non_admin_customer_revoke_admin()
        {
            //Arrange
            CustomerController controller = new CustomerController(new CustomerBLL(new CustomerDALStub()));

            //Act
            var result = (RedirectToRouteResult)controller.revokeAdmin(0);

            //Assert

            Assert.AreEqual("LogIn", result.RouteValues["Action"]);
            Assert.AreEqual("Main", result.RouteValues["Controller"]);
        }
コード例 #3
0
        public void customer_list_customers_sort_customer_desc()
        {
            // Arrange
            TestControllerBuilder builder = new TestControllerBuilder();
            var bll = new CustomerController(new CustomerBLL(new CustomerDALStub()));
            builder.InitializeController(bll);
            builder.HttpContext.Session["loggedInUser"] = new Customer() { admin = true };

            // Act
            var actual = (ViewResult)bll.ListCustomers(null, null, "fname_desc", null, null);
            var result = (IPagedList<UserInfo>)actual.Model;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(string.Compare(result[0].firstname, result[1].firstname) > 0);
        }
コード例 #4
0
        public void test_database()
        {
            TestControllerBuilder builder = new TestControllerBuilder(); 
            //arrange
            var bll = new CustomerController();
            builder.InitializeController(bll);
            builder.HttpContext.Session["loggedInUser"] = new Customer() { admin = true };
            // act
            var actual = (ViewResult)bll.ListCustomers(null, null, null, null, null);
            var result = (IPagedList<UserInfo>)actual.Model;

            //Assert
            Assert.IsTrue(result.Count > 0);
        }  
コード例 #5
0
        public void customer_delete()
        {
            //Arrange
            TestControllerBuilder builder = new TestControllerBuilder();
            var controller = new CustomerController(new CustomerBLL(new CustomerDALStub()));
            builder.InitializeController(controller);
            builder.HttpContext.Session["loggedInUser"] = new Customer() { id = 1, admin = true };

            //Act
            var action = (JsonResult)controller.deleteCustomer(2);
            var success = (bool)(new PrivateObject(action.Data, "success")).Target;

            //Assert
            Assert.IsTrue(success);
        }
コード例 #6
0
        public void customer_list_details()
        {
            // Arrange
            TestControllerBuilder builder = new TestControllerBuilder();
            var bll = new CustomerController(new CustomerBLL(new CustomerDALStub()));
            builder.InitializeController(bll);
            builder.HttpContext.Session["loggedInUser"] = new Customer() { admin = true };

            // Act
            var actual = (ViewResult)bll.CustomerDetails(2);
            var result = actual.Model;

            // Assert
            Assert.IsNotNull(result);
        }
コード例 #7
0
        public void customer_revokeadmin()
        {
            //Arrange
            TestControllerBuilder builder = new TestControllerBuilder();
            var controller = new CustomerController(new CustomerBLL(new CustomerDALStub()));
            builder.InitializeController(controller);
            builder.HttpContext.Session["loggedInUser"] = new Customer() { id = 1, admin = true };

            UserInfo expected = new UserInfo()
            {
                id = 3,
                firstname = "Jens",
                admin = true
            };

            //Act
            var action = (JsonResult)controller.revokeAdmin(expected.id);
            var result = (bool)(new PrivateObject(action.Data, "success")).Target;
            //Assert
            Assert.IsTrue(result);
        }
コード例 #8
0
        public void non_admin_customer_list_customer_orders()
        {
            //Arrange
            CustomerController controller = new CustomerController(new CustomerBLL(new CustomerDALStub()));

            //Act
            var result = (RedirectToRouteResult)controller.ListCustomerOrders(0, null, null, null, null);

            //Assert

            Assert.AreEqual("LogIn", result.RouteValues["Action"]);
            Assert.AreEqual("Main", result.RouteValues["Controller"]);
        }