public void TestFindAll() { IDatabase db = DALFactory.CreateDatabase(); IUserDao dao = DALFactory.CreateUserDao(db); IList <User> entities = dao.findAll(); Assert.AreEqual(entities.Count, 2); }
public void TestFindById() { IDatabase db = DALFactory.CreateDatabase(); IUserDao dao = DALFactory.CreateUserDao(db); User u = dao.findById(1); Assert.AreEqual(u.Id, 1); Assert.AreEqual(u.Email, "*****@*****.**"); }
public void TestFindByUniqueProperty() { IDatabase db = DALFactory.CreateDatabase(); IUserDao dao = DALFactory.CreateUserDao(db); PropertyInfo info = typeof(User).GetProperty("Email"); User u = dao.findByUniqueProperty(info, "*****@*****.**"); Assert.AreEqual(u.Email, "*****@*****.**"); Assert.AreEqual(u.Id, 1); }
public void TestUpdate() { IDatabase db = DALFactory.CreateDatabase(); IUserDao dao = DALFactory.CreateUserDao(db); User u = dao.findById(1); u.FirstName = "Larry"; dao.Update(u); User result = dao.findById(1); Assert.AreEqual(result.FirstName, "Larry"); }
public User AuthenticateAndReturnValidUser(string userName, string password) { IUserDao dao = DALFactory.CreateUserDao(database); HashAlgorithm algo = new SHA256Managed(); byte[] pw = algo.ComputeHash(Encoding.Default.GetBytes(userName + "|" + password)); string pass = System.BitConverter.ToString(pw); User u = dao.findByUniqueProperty(typeof(User).GetProperty("Email"), userName); if (u != null && u.Password.Equals(pass)) { return(u); } return(null); }
public void TestInsert() { IDatabase db = DALFactory.CreateDatabase(); IUserDao dao = DALFactory.CreateUserDao(db); User u = new User(); u.Email = "*****@*****.**"; u.FirstName = "Unit Test"; u.LastName = "Unit Test"; u.Password = "******"; dao.Insert(u); PropertyInfo info = typeof(User).GetProperty("Email"); User result = dao.findByUniqueProperty(info, "*****@*****.**"); Assert.AreEqual(result.Email, "*****@*****.**"); }