public void TestMethodRegisterUser() { inputName = "TestUser"; inputPassword = "******"; inputPasswordV = "ts0987"; inputFullName = "TestUserFull"; bool expectedRegister = true; bool expectedLogin = true; bool expectedDelete = true; var c = new SqlConnection(Properties.Settings.Default.dbConnectionString); bool actualRegister = userRegister.Register(inputName, inputPassword, inputPasswordV, inputFullName); bool actualLogin = userData.LogIn(inputName, inputPassword); int actualUserId = userData.UserID; ds = dbQ.SELECT_FROM_TABLE("SELECT * FROM UserData WHERE UserName = '******'"); int expectedUserId = Int32.Parse(ds.Tables[0].Rows[0]["UserID"].ToString()); Assert.AreEqual(expectedRegister, actualRegister); Assert.AreEqual(expectedLogin, actualLogin); Assert.AreEqual(expectedUserId, actualUserId); DBDelete dbD = new DBDelete(); bool actualDelete = dbD.deleteRow("DELETE FROM UserData WHERE UserName = '******'", c); Assert.AreEqual(expectedDelete, actualDelete); c.Close(); }
public void TestMethodRegisterUser1() { inputName = "Doll"; inputPassword = "******"; inputPasswordV = "lb123"; inputFullName = "User1"; bool expectedRegister = false; var c = new SqlConnection(Properties.Settings.Default.dbConnectionString); bool actualRegister = userRegister.Register(inputName, inputPassword, inputPasswordV, inputFullName); DBDelete dbD = new DBDelete(); bool actualDelete = dbD.deleteRow("DELETE FROM UserData WHERE UserName = '******'", c); Assert.AreEqual(expectedRegister, actualRegister); c.Close(); }
public Boolean DELETE_FROM_TABLE(string stmt) { Boolean flag = false; var conn = new SqlConnection(Properties.Settings.Default.dbConnectionString); DBDelete dbD = new DBDelete(); try { flag = dbD.deleteRow(stmt, conn); return(flag); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); return(false); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } }