コード例 #1
0
ファイル: TestUser.cs プロジェクト: PE-Pmi-32-2020/Books-365
        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();
            }
        }
コード例 #2
0
ファイル: TestUser.cs プロジェクト: PE-Pmi-32-2020/Books-365
        public void TestLoginInvalid()
        {
            TextBox     emailBox = new TextBox();
            PasswordBox pwdBox   = new PasswordBox();

            emailBox.Text   = "*****@*****.**";
            pwdBox.Password = "******";
            Books365.BLL.User user = new Books365.BLL.User();
            using (Books365.AppContext db = new Books365.AppContext())
            {
                Assert.False(user.Login(emailBox, pwdBox));
            }
        }
コード例 #3
0
 private void Button_Click_Login(object sender, RoutedEventArgs e)
 {
     Books365.BLL.User u = new Books365.BLL.User();
     if (u.Login(this.EmailTextBox, this.PasswordTextBox))
     {
         Logger.Info($"User {this.EmailTextBox.Text} - was logged in");
         Window1 w1 = new Window1();
         w1.Show();
         this.Close();
     }
     else
     {
         Logger.Warn($"Login data was incorrect");
     }
 }