package com.gmscheduler.unittests;

import junit.framework.TestCase;
import junit.framework.Assert;
import com.gmscheduler.model.Person;
import com.gmscheduler.model.Timeframe;
import com.gmscheduler.model.Schedule;
import com.gmscheduler.model.LoginUtil;
import com.gmscheduler.model.DatabaseManager;

public class LoginUtilTest extends TestCase {

	private LoginUtil lu = new LoginUtil();
	private DatabaseManager dm = new DatabaseManager();
	private Person p,p1;
	private String s,s1;
	
	protected void setUp() throws Exception {
		s = new String("Beccinator");
		s1 = new String("hermitCrAb");
		p1 = lu.createUser(s,s1);
	}
	
	
	protected void tearDown() throws Exception {
		p1 = lu.login(s,s1);
		dm.deletePerson(p1);
		super.tearDown();
	}
	
	public void testCreateUser() {
		Assert.assertTrue(!p1.isEmpty());

		Assert.assertEquals(p1.getName(),s);
		Assert.assertEquals(p1.getPassword(),s1);
	}
	
	public void testLogin() {
		p1 = lu.createUser("NewFillo-Dough","phatmomma");
		p1 = lu.login("NewFillo-Dough","phatmomma");

		Assert.assertTrue(!p1.isEmpty());
	}
	
}