コード例 #1
0
        public void ModifyWrongTest()
        {
            var ctrl     = new ManageEmployeeController();
            var employee = new Employee()
            {
                UserName   = "******",
                Permission = Permission.Accountant,
            };

            employee.SetSecurePass("2spooky4you");

            // manually add the employee in order to create less of a dependency
            // on CreateEmployeeController
            ctrl.Mgr.EmployeeSet.Add(employee);

            var WrongEmployee = new Employee()
            {
                UserName   = "******",
                Permission = Permission.Accountant,
            };

            WrongEmployee.SetSecurePass("2spooky4you");
            var newUser       = "******";
            var newPass       = "******";
            var newConfPass   = "******";
            var newPermission = "Manager";

            ctrl.Modify(
                userName: newUser,
                password: newPass,
                confPass: newConfPass,
                permission: newPermission,
                emp: WrongEmployee
                );
        }
コード例 #2
0
        public void ModifyTest()
        {
            var ctrl     = new ManageEmployeeController();
            var employee = new Employee()
            {
                UserName   = "******",
                Permission = Permission.Accountant,
            };

            employee.SetSecurePass("2spooky4you");
            // manually add the employee in order to create less of a dependency
            // on CreateEmployeeController
            ctrl.Mgr.EmployeeSet.Add(employee);
            var newUser          = "******";
            var newPass          = "******";
            var newConfPass      = "******";
            var newPermission    = "Manager";
            var newNewPermission = "Plan Admin";


            // if this fails an exception will be fired
            int success = ctrl.Modify(
                newUser,
                newPass,
                newConfPass,
                newPermission,
                employee
                );

            int successAgain = ctrl.Modify(
                userName: newUser,
                password: "",
                confPass: "",
                permission: newNewPermission,
                emp: employee
                );

            Assert.AreEqual(success, successAgain);
            Assert.AreEqual(newUser, employee.UserName);
            Assert.AreEqual(Permission.PlanAdmin, employee.Permission);
        }