package src.hibernatebb.unittests;

import junit.framework.TestCase;
import junit.framework.Assert;
import src.hibernatebb.discussion.User;
import src.hibernatebb.discussion.BoardManager;

public class UserTest extends TestCase {
	BoardManager bm = new BoardManager();
	User u1,u2,u3,u4;
	
	protected void setUp() throws Exception {
		u1 = new User("JoMomma","JoOky");
		bm.saveUser(u1);
	}

	protected void tearDown() throws Exception {
		bm.removeUser(u1.getID());
		super.tearDown();
	}
	
	public void testUserLoad() {
		u2 = bm.loadUser(u1.getID());
		Assert.assertEquals(u1.getID()+u1.getPassword(),u2.getID()+u2.getPassword());
	}
	
	public void testUserSave() throws Exception {
		u3 = new User("j$Money","jookY");
		bm.saveUser(u3);
		
		u4 = new User(bm.loadUser(u3.getID()));
		Assert.assertEquals("j$Money"+"jookY",u4.getID()+u4.getPassword());
	}
	
}
