Ejemplo n.º 1
0
        public void TestChangePassword()
        {
            TextBox     testFirstNameBox = new TextBox();
            TextBox     testLastNameBox  = new TextBox();
            PasswordBox testPasswordBox  = new PasswordBox();
            TextBox     testEmailBox     = new TextBox();
            TextBox     testSecretPinBox = new TextBox();

            testFirstNameBox.Text    = "name";
            testLastNameBox.Text     = "surname";
            testPasswordBox.Password = "******";
            testEmailBox.Text        = "*****@*****.**";
            testSecretPinBox.Text    = "1234";

            Books365.BLL.User user = new Books365.BLL.User();
            using (Books365.AppContext db = new Books365.AppContext())
            {
                TextBox testNewPasswordBox = new TextBox();
                testNewPasswordBox.Text = "NewPassword";
                user.AddNewUser(testFirstNameBox, testLastNameBox, testPasswordBox, testEmailBox, testSecretPinBox);
                user.ChangePassword(testEmailBox.Text, testSecretPinBox, testNewPasswordBox);
                Assert.Equal(testNewPasswordBox.Text, db.Users.Where(u => u.Email == testEmailBox.Text).FirstOrDefault().Password);
                db.Users.RemoveRange(db.Users.Where(u => u.Email == testEmailBox.Text));
                db.EmailCurrentUser.RemoveRange(db.EmailCurrentUser.Where(u => u.Email == testEmailBox.Text));
                db.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public void TestLoginValid()
        {
            TextBox     testFirstNameBox = new TextBox();
            TextBox     testLastNameBox  = new TextBox();
            PasswordBox testPasswordBox  = new PasswordBox();
            TextBox     testEmailBox     = new TextBox();
            TextBox     testSecretPinBox = new TextBox();

            testFirstNameBox.Text    = "name";
            testLastNameBox.Text     = "surname";
            testPasswordBox.Password = "******";
            testEmailBox.Text        = "*****@*****.**";
            testSecretPinBox.Text    = "1234";

            Books365.BLL.User user = new Books365.BLL.User();
            using (Books365.AppContext db = new Books365.AppContext())
            {
                user.AddNewUser(testFirstNameBox, testLastNameBox, testPasswordBox, testEmailBox, testSecretPinBox);
                db.EmailCurrentUser.RemoveRange(db.EmailCurrentUser.Where(u => u.Email == testEmailBox.Text));
                db.SaveChanges();
                Assert.True(user.Login(testEmailBox, testPasswordBox));
                db.Users.RemoveRange(db.Users.Where(u => u.Email == testEmailBox.Text));
                db.EmailCurrentUser.RemoveRange(db.EmailCurrentUser.Where(u => u.Email == testEmailBox.Text));
                db.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        private void Button_Click_Reg(object sender, RoutedEventArgs e)
        {
            Validator validator = new Validator();

            if (validator.IsEmpty(this.Email_Register) ||
                !validator.EmailIsCorrect(this.Email_Register) ||
                validator.IsEmpty(this.LastNameTextBox) ||
                validator.IsEmpty(this.FirstNameTextBox) ||
                validator.IsEmpty(this.SecretPinTextBox) ||
                validator.EmailExists(this.Email_Register) ||
                !validator.SecretPinIsCorrect(this.SecretPinTextBox) ||
                !validator.PasswordIsCorrect(this.Password_Register))
            {
            }
            else
            {
                Books365.BLL.User user = new Books365.BLL.User();
                user.AddNewUser(this.FirstNameTextBox, this.LastNameTextBox, this.Password_Register, this.Email_Register, this.SecretPinTextBox);
                Window1 w1 = new Window1();
                w1.Show();
                this.Close();
            }
        }