public void initialize() { session = new session(); user = new user(); user.email = "*****@*****.**"; user.password = "******"; user.age = 33; }
[TestMethod] public void domain_member_and_column_name_differ_but_are_mapped() { var age = user.age; session.insert(user); user = session .param("@email", user.email) .one<user>("where email = @email"); assert(user.age == age); }
[TestMethod] public void dispose_connection() { using (session.open_connection()) { session.insert(user); user = session .param("@email", user.email) .one<user>("where email=@email"); } assert(user.email != null); }
[TestMethod] public void share_connection() { var email = user.email; var session = new session().open_connection(); session.insert(user); user = session .param("@email", email) .one<user>("where email=@email"); session.close_connection(); assert(user.email == email); }
[TestMethod] public void insert_update_select_delete() { var user = new user(); user.email = "*****@*****.**"; user.password = "******"; user.id = db.insert(user); assert(user.id > 0); user.password = "******"; var rows_affected = db.update(user); assert(rows_affected == 1); user = db.one<user>(user.id); assert(user.password == "new"); rows_affected = db.delete<user>(user.id); assert(rows_affected == 1); // throws exception since user does not exist //user = db.one<user>(user.id); //assert(user.id == 0); }
[TestMethod] public void prepare_database() { var user = new user() { email="*****@*****.**", password="******" }; db.insert<user>(user); }
[TestMethod] public void rollback_uncommitted_transaction() { var id = session.insert(user); var email = user.email; var updated_email = "*****@*****.**"; using (session.start_transaction()) session .execute("update users set email = '{0}'" .plug(updated_email)); user = session.one<user>(id); assert(user.email == email); assert(user.email != updated_email); }