Esempio n. 1
0
        public void CreateNewStudent_NewStudent_NewStudentCreated()
        {
            //Arrange

            PersonVM modelTest = new PersonVM()
            {
                LastName        = "Green",
                FirstMidName    = "Harry",
                Login           = "******",
                Password        = "******",
                ConfirmPassword = "******",
                Role            = "student"
            };
            //Ceci rend le test dependant de la methode GenerateSHA256String(string inputString) de la Classe HashService
            string passwordTest = HashService.GenerateSHA256String(modelTest.Password);

            //Act
            authenticationBusinessToTest.CreateNewStudent(modelTest);
            Student student = DBUtils.db.Students.SingleOrDefault(s => s.LastName == "Green" && s.FirstMidName == "Harry" && s.Login == "login1" && s.Password == passwordTest);

            //Assert

            Assert.IsNotNull(student);
        }
Esempio 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());
        }