private static List<User> getUsers() { ISession session = GetNHibernateSession(); User userLogin = new User(); List<User> users = new List<User>(); users = (from u in session.Query<User>() select u).ToList<User>(); return users; }
public void AddUserTest() { User newUser = new User(); string username = "******"; string password = "******"; if(!Account.IsUserRegistered(username)) { newUser.username = username; newUser.password = password; //Account.AddNewUser(newUser); } bool isRegister = Account.IsUserRegistered("huang"); Assert.AreEqual(false,isRegister); }
public static void AddNewUser(User newUser) { ISession session = GetNHibernateSession(); session.Save(newUser); }
public void DatabaseConnTest() { //UserLogin userLogin = new UserLogin(); //bool userRegister = userLogin.IsUserRegistered("zhangsan"); //Assert.AreEqual(false, userRegister); Configuration cfg = new Configuration(); cfg.AddAssembly("DataModels"); ISessionFactory factory = cfg.BuildSessionFactory(); ISession session = factory.OpenSession(); ITransaction tx = session.BeginTransaction(); User loginTest = new User(); loginTest = session.Get<User>(1); tx.Commit(); session.Close(); factory.Close(); Assert.AreEqual(loginTest.password, "hz2006"); }