public void DeleteUserTest()
        {
            var user = UserMetier.GetUser("99");
            var rows = UserMetier.DeleteUser(user.Id);

            Assert.IsTrue(rows > 0);
        }
        public void ValidationUserDTOThrowExceptionTest()
        {
            // yl - initialisation metier.
            var lMetier = new UserMetier();

            // yl - On lance la methode "ValidatedDTO" avec un paramettre invalide. => Une exception de type UserException doit etre lever
            lMetier.ValidatedDTO(new CritereUserDTO());
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            var user = UserMetier.GetUser(tbLogin.Text, tbPass.Text);

            if (!user.IsEmpty())
            {
                dispatcher.IdentificationService.StoreSession(user);
                dispatcher.IdentificationService.SetLoggedUser(user);
                this.Response.RedirectToRoute("Index");
            }
            else
            {
                lblError.Visible = true;
            }
        }
        public void FailInsertTest()
        {
            var sqlParams = new Dictionary <string, object>()
            {
                { "Login", testUser.Login },
                { "Pass", testUser.Pass },
                { "IdType", testUser.IdType },
                { "Nom", testUser.Nom },
                { "Prenom", testUser.Prenom },
                { "DateRegister", testUser.DateRegister },
            };
            var id = UserMetier.InsertUser(sqlParams);

            Assert.IsTrue(id <= 0);
        }
        public void UpdateUserTest()
        {
            var user      = UserMetier.GetUser("99");
            var sqlParams = new Dictionary <string, object>()
            {
                { "IdType", testUser.IdType },
                { "Nom", "Unit Test Nom Update" },
                { "Prenom", "Unit Test Nom Update" },
                { "DateRegister", DateTime.Now },
                { "Id", user.Id }
            };
            var id = UserMetier.UpdateUser(sqlParams);

            Assert.IsTrue(id == 1);
        }
        public void InsertUserTest()
        {
            var sqlParams = new Dictionary <string, object>()
            {
                { "Login", "99" },
                { "Pass", "99" },
                { "IdType", 1 },
                { "Nom", "Unit Test Nom" },
                { "Prenom", "Unit Test Prenom" },
                { "DateRegister", DateTime.Now },
            };
            var id      = UserMetier.InsertUser(sqlParams);
            var newUser = UserMetier.GetUser(id);

            Assert.IsTrue(newUser.Login.Equals("99"));
        }
 public void ValidationUserCritereDTOThrowExceptionTest()
 {
     try
     {
         // yl - initialisation metier.
         var lMetier = new UserMetier();
         // yl - On lance la methode "ValidatedCritere" avec un paramettre invalide.
         lMetier.ValidatedCritere(new UserDTO());
     }
     catch (Exception ex)
     {
         // yl - une exception est lever. le test est réussi.
         return;
     }
     // yl - si aucune exception lever c'est un FAIL.
     Assert.Fail("Aucune exception lever");
 }
Example #8
0
        protected void btnValidate_Click(object sender, EventArgs e)
        {
            lblSuccessUpdate.Visible = lblErrorLogin.Visible = false;
            var curUser    = dispatcher.IdentificationService.GetLoggedUser();
            var updUser    = GetClonedUser(curUser);
            var sqlParams  = new Dictionary <string, object>(8);
            var typeCompte = !String.IsNullOrEmpty(ddlTypeCompte.SelectedValue) ? Convert.ToInt32(ddlTypeCompte.SelectedValue) : 0;

            if (!tbLogin.Text.Equals(curUser.Login))
            {
                var user = UserMetier.GetUser(tbLogin.Text);
                if (!user.IsEmpty())
                {
                    lblErrorLogin.Visible = true;
                    return;
                }
                sqlParams.Add("Login", tbLogin.Text);
                updUser.Login = tbLogin.Text;
            }
            if (!tbPass.Text.Equals(curUser.Pass))
            {
                sqlParams.Add("Pass", tbPass.Text);
                updUser.Pass = tbPass.Text;
                tbPass.Attributes["value"] = tbPass.Text;
            }
            if (typeCompte != curUser.IdType)
            {
                sqlParams.Add("IdType", typeCompte);
                updUser.IdType           = typeCompte;
                updUser.UserType.Id      = typeCompte;
                updUser.UserType.NameStr = ddlTypeCompte.SelectedItem.Text;
            }
            if (sqlParams.Count > 0)
            {
                sqlParams.Add("Id", curUser.Id);
            }
            int rows;

            if ((rows = UserMetier.UpdateUser(sqlParams)) > 0)
            {
                ReloadUserData(ref curUser, updUser);
                LoadUserInfo(curUser);
                UpdateMasterReference(curUser);
                lblSuccessUpdate.Visible = true;
            }
        }
Example #9
0
        protected void btnInscrire_Click(object sender, EventArgs e)
        {
            var user         = UserMetier.GetUser(tbLogin.Text);
            var date         = DateTime.Now;
            var selectedType = ddlTypeUser.SelectedItem;
            var idType       = Convert.ToInt32(selectedType.Value);

            if (!user.IsEmpty())
            {
                lblLoginError.Visible = true;
                return;
            }
            var sqlVals = new Dictionary <string, object>(8)
            {
                { "Login", tbLogin.Text },
                { "Pass", tbPassword.Text },
                { "Nom", tbNom.Text },
                { "Prenom", tbPrenom.Text },
                { "IdType", idType },
                { "DateRegister", date },
            };
            int id;

            if ((id = UserMetier.InsertUser(sqlVals)) > 0)
            {
                user.Id               = id;
                user.DateRegister     = date;
                user.IdType           = idType;
                user.Login            = tbLogin.Text;
                user.Pass             = tbPassword.Text;
                user.Prenom           = tbPrenom.Text;
                user.Nom              = tbNom.Text;
                user.UserType.Id      = idType;
                user.UserType.NameStr = selectedType.Text;

                dispatcher.IdentificationService.SetLoggedUser(user);
                dispatcher.IdentificationService.StoreSession(user);
                this.Response.RedirectToRoute("Index");
            }
        }
        public void GetUserById()
        {
            var user = UserMetier.GetUser(testUser.Id);

            Assert.IsTrue(user.Equals(testUser));
        }
        public void GetUserByLoginPasswordTest()
        {
            var user = UserMetier.GetUser(testUser.Login, testUser.Pass);

            Assert.IsTrue(user.Equals(testUser));
        }
        public void GetUserByLoginTest()
        {
            var user = UserMetier.GetUser(testUser.Login);

            Assert.IsTrue(user.Equals(testUser));
        }