Ejemplo n.º 1
0
        public void CreateNewInstructor_NewInstructor_NewInstructorCreated()
        {
            //Arrange

            PersonVM modelTest = new PersonVM()
            {
                LastName        = "Green",
                FirstMidName    = "Harry",
                Login           = "******",
                Password        = "******",
                ConfirmPassword = "******",
                Role            = "instructor"
            };

            //Ceci rend le test dependant de la methode GenerateSHA256String(string inputString) de la Classe HashService
            string passwordTest = HashService.GenerateSHA256String(modelTest.Password);

            //Act
            authenticationBusinessToTest.CreateNewInstructor(modelTest);
            Instructor instructor = DBUtils.db.Instructors.SingleOrDefault(s => s.LastName == "Green" && s.FirstMidName == "Harry" && s.Login == "login1" && s.Password == passwordTest);

            //Assert

            Assert.IsNotNull(instructor);
        }
Ejemplo n.º 2
0
        public ActionResult Register(PersonVM model)
        {
            if (ModelState.IsValid)
            {
                UsernameValidation user = new UsernameValidation();
                if (user.UsernameIsAvailable(model.Login) == true && model.Role == "Student")
                {
                    AuthenticationBusiness student = new AuthenticationBusiness();
                    student.CreateNewStudent(model);
                    ViewBag.MessageSuccess = "Registration successful !";
                    return(RedirectToAction("Login"));
                }

                else if (user.UsernameIsAvailable(model.Login) == true && model.Role == "Instructor")
                {
                    AuthenticationBusiness instructor = new AuthenticationBusiness();
                    instructor.CreateNewInstructor(model);
                    ViewBag.MessageSuccess = "Registration successful !";
                    return(RedirectToAction("Login"));
                }
            }

            return(View());
        }