コード例 #1
0
        public void EmployeesController_Details_isNotValid()
        {
            EmployeesController controller = new EmployeesController();

            HttpNotFoundResult result = controller.Details(9999999) as HttpNotFoundResult;
            var expectedResult = new HttpNotFoundResult().GetType();

            Assert.IsInstanceOfType(result, expectedResult);
        }
コード例 #2
0
        public void EmployeesController_Delete_GET_isValid()
        {
            EmployeesController controller = new EmployeesController();

            ViewResult result = controller.Delete(1) as ViewResult;
            Employee EmployeesResult = (Employee)result.Model;

            Assert.AreEqual(1, EmployeesResult.employeeID);
        }
コード例 #3
0
        public void EmployeesController_Create_isNotValid()
        {
            Employee testEmployee = new Employee();
            testEmployee.employeeFirstName = "invalidEmployee";
            EmployeesController controller = new EmployeesController();
            controller.ModelState.AddModelError("", "error message");

            var result = controller.Create(testEmployee) as ViewResult;
            Employee resultEmployees = (Employee)result.Model;

            Assert.AreEqual("invalidEmployee", resultEmployees.employeeFirstName);
        }
コード例 #4
0
        public void EmployeesController_Create_isValid()
        {
            Employee testEmployee = new Employee();
            testEmployee.employeeDepartment = "Sales";
            testEmployee.employeeEmail = "*****@*****.**";
            testEmployee.employeeStreet = "test street";
            testEmployee.employeeFirstName = "TestEmp";
            testEmployee.employeeLastName = "TestLast";

            EmployeesController controller = new EmployeesController();

            var result = (RedirectToRouteResult)controller.Create(testEmployee);

            Assert.AreEqual("Index", result.RouteValues["action"]);
        }
コード例 #5
0
        public void EmployeesController_Details_isValid()
        {
            EmployeesController controller = new EmployeesController();

            ViewResult result = controller.Details(1) as ViewResult;
            Employee employeeResult = (Employee)result.Model;

            Assert.AreEqual(1, employeeResult.employeeID);
        }
コード例 #6
0
        public void EmployeesController_Index()
        {
            EmployeesController controller = new EmployeesController();

            ViewResult result = controller.Index() as ViewResult;

            Assert.IsNotNull(result.Model);
        }